Comments (10)
Hi,
Are you seeing this behavior when running in development mode with runserver? Or is this happening with a daphne deployment, and possibly you're running multiple instances?
from django-eventstream.
I'm running in development mode with runserver.
from django-eventstream.
I tried running the time example (in this repo) using the latest versions of all dependencies, including Django 3, and it seemed to work fine. Does it work for you too?
from django-eventstream.
I tried running the chat example, with Django 3 and it worked fine.
from django-eventstream.
Debugging further is difficult. The library could probably use some debug logging.
All I can suggest is to use curl to connect to the events endpoint in order to examine the raw stream. Also try to think about what is different with your app vs the chat example (use of threads, etc).
from django-eventstream.
I got the same result as before using curl.
I'm using a separate thread to call send_event(...). Do you think that can be the reason to observe this pattern? If yes, can you explain or do you know why that can be a problem?
from django-eventstream.
send_event
is intended to be thread safe, and the time example calls it from a separate thread too, so it should be okay. But perhaps there is some extra complexity in your app that could be interfering. Are you sure send_event is actually getting called the number of times you expect? Are you using some kind of parallelization library that converts threads into processes?
from django-eventstream.
Can you trim your code down to a reproducible example and share it?
from django-eventstream.
I was sure that I was calling the send_event
the number of times I was expecting.
I think I have the problem solved. But I'm not sure that I know exactly what was causing this issue.
The code that was calling the send_event
was being initiated in the AppConfig.ready()
. I don't know if this function was being initiated more than one time. Once I started calling python manage.py runserver
with the option --noreload
, the stream started receiving all the events as it should.
I think it is a solution for now, but I would like to understand better what was happening.
I would prefer to be able to use the runserver
without the option --noreload
.
Anyway, Thanks for your help!
from django-eventstream.
Glad to hear you've found a solution. I tried moving the time example's thread init to AppConfig.ready()
and it still worked okay, even after modifying a file and letting it reload. An asgiref error was logged though.
Django's runserver reloading is tricky business and it wouldn't surprise me if there is some bug with it or in combination with Channels. Maybe upgrade your Daphne: django/channels#1374
from django-eventstream.
Related Issues (20)
- django 2.2 implement alongside websockets and i get a AttributeError: module 'django_eventstream.urls' has no attribute 'callback' HOT 2
- Can't parse stream-error data into json HOT 2
- Client keep sending requests even if it receives a refuse answer HOT 2
- events not delivered when using pushpin path_beg, replace_beg on route HOT 1
- Support current version of Django and Django Channels HOT 1
- trouble installing HOT 1
- use redis as the event storage backend HOT 4
- Do I need close channels when all data are sent? HOT 2
- Why there is a hardcoded channel name prefix `events-` in case of pushpin proxy HOT 3
- send_event not sending an event in localhost HOT 4
- Support ZeroMQ HOT 1
- What is the difference between evenstream and websockets? HOT 2
- Does not work for utf-8 symbols HOT 1
- Headers are missing in django-eventstream url patterns HOT 1
- Support for django-rq HOT 1
- ModuleNotFoundError: No module named 'channels.http' HOT 3
- CORS Error: How can we allow multiple origins HOT 2
- Compatibility with htmx HOT 5
- How to run examples using Uvicorn? HOT 4
- AttributeError: 'ASGIRequest' object has no attribute 'grip' HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-eventstream.