Open ghost opened 12 years ago
Fixing _lctx would do the job for most of bottle. Everything is based on that single thread-local. Only the reloading feature uses threads, sleep, interrupt_main() and such.
So, your idea is feasible, if we can generalize the reloading stuff in a way that is easily switchable between threads and greenlets.
How feasible is it to monkey patch bottle to use gevent/greenlet facilities where applicable rather than rely on gevent's monkey patching of the standard library? while I'm currently using gevent, I also prefer to avoid gevent's monkey patching - I know some people view the convenient monkey patching as part of the point of using gevent, but it does work usefully without it.
Maybe a
bottle.gevent_myself()
could be added (you're in a better position than me to know what exactly would need patching, but to me it just looks like the_lctx
,localproperty
and anything using it i.e.LocalRequest
/LocalResponse
stuff). That way bottle wouldn't need gevent monkey patching to have taken place (or cause it to take place, either i.e. I mean a function that switches bottle over to use greenlet.local etc. where necessary, not a function that just calls gevent.monkey stuff).