squeaky-pl / japronto

Screaming-fast Python 3.5+ HTTP toolkit integrated with pipelining HTTP server based on uvloop and picohttpparser.
MIT License
8.61k stars 581 forks source link

Issue with threading #135

Closed mak-shah closed 5 years ago

mak-shah commented 6 years ago

Hi,

I am trying to use this framework instead of my flask framework, as the current framework handles the connections very good , on the other hand I am facing the issue with the multi threading,

I have created two threads, consumer and producer with one shared object between them, which is of type python dictionary, the issue is rather than creating a second thread, it is creating a second process, I am posting it here, because same code is running in flask framework properly, so I don't think it is something related to the code I have written, is there a multi threading support in proper manner ?

I have chose this framework considering the better network connections handling, but on the other hand I am facing this threading related issue.

Please help. Thanks

squeaky-pl commented 6 years ago

It's hard to speculate without an actual example but you are probably creating your threads at the import time and then trying to share something with the request handler that is run in a separate process (since japronto is a fork abusing server).

You can circumvent by creating both of your threads in the request handler lazily.