-
-
Notifications
You must be signed in to change notification settings - Fork 888
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
Request.post to a high latency external URL causes interruption in SocketIO , Running inside Docker. #961
Comments
First of all, move the monkey patching to the top of your application's main module. You do not need to do the Besides that I'm not sure what the problem might be. With the monkey patching socket operations become non-blocking so I don't see anything in the code snippet you posted that could cause blocking. |
Thank you for the instant reply , So , there should not be any blocking issue . I'll search for the bottleneck . Can we yet use |
No, eventlet and asyncio are competing async frameworks, they don't work together. |
Is it possible to emit to an external url ? either from server or fronted , i want to do the following functionality using api_url = 'https://example.com'
requests.post(api_url, json=mydata, headers=head) |
@Fizmath you can only emit to a Socket.IO server. The code that you pasted above sends an HTTP request, which is a more basic protocol than Socket.IO. Why do you need to use Socket.IO for this? If your server accepts HTTP requests, then use |
Because this is real-time data analysis : fronted sends streaming data to the server via |
Can i use Celery and Redis ... for |
Do you have control over this external server? If you do, then add a Socket.IO server there, and then you can emit to it. |
No , i can only My app runs from Docker image , if yes , i should make What is your suggestion ? |
@Fizmath there are a hundred different ways to do this. Yes, you can use Celery, you can also use a child process, or a background thread. Regardless, sending a post request from an eventlet app is non-blocking, so your server should be operational. If you don't want to delay the response to your client, then start a background task and do it from there. Something like this:
That is as non-blocking as using Celery, etc. |
SOLVED ! : I found the solution . I did not mention that i ran the code inside https://github.com/kennethreitz/requests/issues/3948 from there , i degraded the libraries in my
then rebuilt and launched the docker image and the Anyway , thank you Miguel for your kind remarks and instant replies . I changed the title for those who google . |
Hello dear Miguel ,
Below is the simplified code : the
x
thread does real-time Postingmydata
( this came from fronted within SocketIo then get processed before POST) to an external website that loads slowly so the whole SocketIo hangs for a second until the POST accomplished . I also usedTimeout
but the website gets the POST not less than 1 second , i need to send every 1 millisecond .Anyway , websites might be slow or proxies or whatsoever . How can i POST not blocking the main thread
dd
?The text was updated successfully, but these errors were encountered: