-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
JPEG Camera Streaming #1173
Comments
Streaming in Sanic takes a function that can write directly to the response, not a generator. So you'd probably need to structure your code like
|
If anyone is wondering, I solved it with this code
Although, the code before this comment by @nhydock works too. Thank you! |
In sanic you should be getting the event loop from the request object just to be safe You might actually want to run your camera frame fetching in an async task on sanic as described in the Middleware docs and store the frame in memory, then have your streams fetch the stored frame instead of make a request to the camera. That way you don't have too many IO connections open to it, which can improve throughput. Glad to see that you are able to stream data from your camera, though, that's pretty cool. |
@nhydock My code hangs after 5-10 seconds. Any idea why and how can I solve it? Thank you so much. |
@nhydock as of Python 3.5.3 Anyway, |
ah, sorry, that was my misunderstanding from looking at the deployment docs, which state
The api docs/code say it's the same as Anyway, streaming problems with synchronous write would be related to #1067 |
@asvetlov I'm not able to see any errors, it hungs up the system and my remote wi-fi connection gets interrupted until the program closes itself or I reboot it. But I suspect it's a memory error too. @nhydock I checked it out before, but couldn't figure out how to implement it on my case. It's basically splitting the data on chunks if I got it right, but I don't have any file to split. Thank you so much for your efforts |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is incorrect, please respond with an update. Thank you for your contributions. |
It's probably fixed by #1179 |
Probably due to my python knowledge level, I can't make it work with Sanic. I had this piece of code when I was on Flask :
The problem is, I can't use plain "response" function to replace "return Response" because it has no mimetype or content_type. There's a stream function in sanic but whenever I use it , I get this TypeError: 'generator' object is not callable error and I don't know how to flip the boards. Any ideas? Thank you
P.S: Sorry, I know you guys are busy with engineering problems but I have been baffling with this for a week now. I could really use some ideas. Thank you.
The text was updated successfully, but these errors were encountered: