You don't show us any of what you're doing to import APIs or launch greenlets, so I will have to make a bunch of guesses. (In the future, please try to provide complete examples. See http://sscce.org
If you want to use greenlets and gevent to execute functions in parallel, the functions that you want to execute must cooperate with gevent. Be sure you've read and understood http://www.gevent.org/intro.html
Typically, that means you need to use gevent's modules, not the standard library modules, to perform things like sleeping and network IO.
This can be done by putting `from gevent import monkey; monkey.patch_all()` at the start of your script. (That's the way I usually recommend.) You may also choose to import specific gevent APIs, for example, `from gevent.time import sleep`.
You then need to start your functions in greenlets, and give them an opportunity to run.
Putting that together, your code should look something like this:
from gevent import monkey; monkey.patch_all() # MUST BE FIRST
from time import sleep
<your code here>
<your code here>
greenlets = [gevent.spawn(aaaa), gevent.spawn(bbbb)]
gevent.joinall(greenlets) # Let them run; could do other gevent things here
It's important to note that regular files that you get from `open` generally DO NOT cooperate with gevent. That means you cannot read from or write to normal files in parallel (reading/writing a file blocks the gevent event loop). Usually reading/writing a regular file is so fast that this doesn't matter much. However, in the chance that profiling shows that reading from normal files is holding up your program (for example, because the files are actually located on a slow network file system) you'll need to use operating-system threads to achieve further concurrency in Python. You can do this in a bunch of ways, including using gevent's `FileObjectThread` (http://www.gevent.org/api/gevent.fileobject.html
) as a wrapper (e.g., `with FileObjectThread(open("a.txt")) as fw:`).
> You received this message because you are subscribed to the Google Groups "gevent: coroutine-based Python network library" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to gevent+un...@googlegroups.com
> To view this discussion on the web visit https://groups.google.com/d/msgid/gevent/08a70bad-269b-4e0e-8f98-d5f90e6dce5do%40googlegroups.com