New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migration to Gevent #2029
Migration to Gevent #2029
Conversation
Also for the longer test, there is some stackoverflow answer. But I didn't test it. |
eventlet.wsgi.server(eventlet.listen((host, int(port)), s_type), app) | ||
|
||
ssl_args = {} | ||
sock = WSGIServer.get_listener((host, port), family=s_type) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested with Netstat, ipv6 also works(?). FYI, http://[::1]:5000
sys.exit() | ||
cd_server.stop() | ||
cd_server.close() | ||
print('Shutdown Success', file=sys.stderr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just for logging.
by the way, the application MUST stay as a single-threaded application this is because the data-structure is stored as a single dict, and running separate threads in gevent/flask means each thread gets its own datastructure, which is bad. this explains your random failures it is more like Redis than a traditional system where it has an external database |
@@ -1,4 +1,4 @@ | |||
eventlet>=0.33.3 # related to dnspython fixes | |||
gevent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
related to dnspython fixes
also means we can maybe un-pin some package versions.. i wonder
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh the dnspython
I will apply it later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eventlet/eventlet#781 is that 'dnspython' problem i believe, but actually it may not be a 'thing' anymore
then the reason why my CD works well is I don't do massive things frequently, haha. |
maybe gunicorn is an alternative too? |
@dgtlmoon gunicorn won't work with Windows. https://github.com/benoitc/gunicorn/blob/26aba9ed9d55f6465fd2271169b71bc119ea8186/pyproject.toml#L17 |
I'm not sure about when I can finish this (maybe 2-3 months?). Please ignore any CI activities related to this PR until I'm prepared. Thanks. |
The main problem here is that one thread is holding all the data, usually one would use something like mysql or whatever to keep the data in a resource that's accessible to any thread.. I would prefer to keep the application running without any need for mysql/mongo/etc/etc The main solution would be that the data structure needs to be in some shared-memory resource between each thread, but this is unreliable a little bit in windows/mac.. unless theres some python library that will help https://docs.python.org/3/library/multiprocessing.shared_memory.html for example or move to gevent but keep exactly 1 thread only (like it is now) i dont think there's much to win right now... better to move to multilang or some other feature perhaps (but ofcourse its up to you :) ) |
Yeah because Python is the single-threaded model, one process-one main thread (and C extension module..). That's something tempting. Okay, why not Babel first? I will look at it. If my intuition is right, I can lay the foundation this week? |
sure :) thanks a billion :) |
Co-authored-by: dgtlmoon <leigh@morresi.net>
https://wsgi.readthedocs.io/en/latest/definitions.html since gevent just implements the WSGI standard, the flags are the same. https://wsgi.readthedocs.io/en/latest/definitions.html#envvar-wsgi.multithread https://wsgi.readthedocs.io/en/latest/definitions.html#envvar-wsgi.multiprocess I think |
https://code.google.com/archive/p/modwsgi/wikis/ProcessesAndThreading.wiki ahh |
Some history on the pinned |
See also: https://eventlet.readthedocs.io/en/latest/migration.html#alternatives
|
aaah... yeah thanks for the find, it is true that async code is better
ok so eventlet and gevent are actually blocking-style wrappers ontop of what is really a asyncio on the "ground level" in python... so yeah thats kinda tough |
I still think gevent is the way to go, it looks well maintained https://www.gevent.org/changelog.html we can add some comment that "gevent is just a blocking wrapper ontop of what is really a asyncio interface at its heart, but due to our not-shared-across-processes datastructure (so you dont ever have to waste time setting up mysql etc) we have a single threaded model" |
I'm learning more about doing fun stuff with python dicts, so i hope we can move to maybe even a sqlite backend in the future |
I closed this because I saw the gevent won't work for future python version too.(there was CPython issue similar to eventlet) |
Understood, I'm sort of thinking it may be time to start migrating to SQLite in the backend and do things more traditionally so that we can run it multithreaded |
I just assume and believe I know the reason. I don't know what to do currently.