How to get the size of a byte
import struct
size = struct.calcsize(b"test")- When you want to use
Threadclass to do some thread-relating work, you can initialzeThreadclass by customize arguments and useThread.start()to let the job start running, and make sure you should overrideThread.run()instead of directly invoke
- When Queue is initialized, the
unfinished_tasksis also set to be0, it would keep increased whenputmethod is invoked, but it do not decresed whengetmethod is invoked on contrary. The only way to make it decreasing is to invoketask_donefrom outside
according to interpreter document, python support typing [ctrl-p] to retreive history command and other arrow button to do editing,
it all depends on GUN readline library, its a very useful tool to do some just in time test.
but with unknown reason, it just not working at my ubuntu machine, like when I click "up" button,
it outputs the "^[[A" which was suppose to be history command like "exit()"
here is my solution, it may not work for you, its a simple record here.
$ conda/pip uninstall readline
for more details and further resource, you can check out below:
GUN readline
python interpreter
https://stackoverflow.com/questions/71595635/render-numpy-array-in-fastapi/71639658#71639658
-
When the uvicorn start a server, it first load the config as follow:
config = Config(app, *args, **kwargs) server = Server(config=config)
this loads the
apppath which is not the truly running instance. -
then, the
uvicornsetup the variable_event_loop_policyof python packageasynciotouvloop.EventLoopPolicywhich looks like is aCythonclass that designed to speed up the server executions.asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
-
After the
asyncio's environment is ready, theuvicorninstantly start all the synchronize services.config.load() # this truely instantiate app class with configs. await server.startup(sockets=sockets) # this creates a TCP server which take full use of uvloop