`go func()` in python
The excellent gevent
has a method that can basically mimic go func()
semantics in go.
Where in go you would write:
go func(arg1, arg2, arg3)
in python with gevent, you would write:
gevent.spawn(func, arg1, arg2, arg3)
This will spawn a greenlet and schedule it to be started. It will execute once the current greenlet yields.
If you’re running in a shell or a one-time script then you need to explicitly yield by calling gevent.sleep(0).
Note that gevent.spawn also accepts keyword arguments (which will be forwarded to the function).
Written by Hasen el Judy
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Python
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#