Skip to content
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

Emit recieved on the client side only after the server-side emit function returns #2

Open
ahmedtalhakhan opened this issue Nov 23, 2013 · 2 comments

Comments

@ahmedtalhakhan
Copy link

I tried to use django-socketio but faced an issue. When an event is emitted from the client-side, it is immediately received on the server side. However, when the server-side emits the event, it is only received when the sending function from the server-side code returns. I tried by sending multiple emits and then returning. Here is the sample code

Here is my events.py

@Namespace('/test')
class TestNs(BaseNamespace):
    def on_test(self,msg):
        for i in range(5):
            self.emit('test','1')
            time.sleep(1)

        time.sleep(10)
        self.emit('test','atlast')

And here is what the client looks like

var socket = io.connect('/test');
socket.emit('test','Send to server');
socket.on('test', function(data){console.log("Got back " + data(})

Client-side shows data when the sender in server-side returns. Am I missing something or is this a buffering issue?

@galuszkak
Copy link
Member

@ahmedtalhakhan
I will test that today and give you feedback. From my perspective should work.

@ahmedtalhakhan
Copy link
Author

It works with gevent.sleep(). I think it has something to do with gevent threads. They ought to know that the application wants to sleep. Just guessing though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants