ValvePython / dota2

🐸 Python package for interacting with Dota 2 Game Coordinator
http://dota2.readthedocs.io
201 stars 32 forks source link

This operation would block forever #25

Closed LadaBr closed 7 years ago

LadaBr commented 7 years ago

I'm trying to launch lobby game after certain amount of time but I always end up getting error.

@dota.on('channel_join')
    def channel_joined(msg):
        nonlocal lobby_channel_id

        lobby_channel_id = msg.channel_id

        nonlocal match_started
        nonlocal count
        nonlocal max_time
        while count < max_time and not match_started:

            if count > max_time - 5:
                mod = 1
            elif count > max_time - 30:
                mod = 5
            elif count > max_time - 60:
                mod = 10
            else:
                mod = 30
            if count % mod == 0:
                dota.send_message(msg.channel_id,"Time remaining: " + str(max_time - count) + " sec")
            count = count + 1
            gevent.sleep(1)

        if not match_started:
            dota.send_message(msg.channel_id,"Starting the game! GL&HF!")
            dota.launch_practice_lobby()

Whenever dota.launch_practice_lobby() is called this error happens:

Exception in thread Thread-4: Traceback (most recent call last): File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner self.run() File "/var/www/django/dotaleague.cz/env/lib/python3.5/site-packages/channels/management/commands/runserver.py", line 164, in run worker.run() File "/var/www/django/dotaleague.cz/env/lib/python3.5/site-packages/channels/worker.py", line 87, in run channel, content = self.channel_layer.receive_many(channels, block=True) File "/var/www/django/dotaleague.cz/env/lib/python3.5/site-packages/asgiref/base_layer.py", line 43, in receive_many return self.receive(channels, block) File "/var/www/django/dotaleague.cz/env/lib/python3.5/site-packages/asgi_redis/core.py", line 152, in receive result = connection.blpop(list_names, timeout=self.blpop_timeout) File "/var/www/django/dotaleague.cz/env/lib/python3.5/site-packages/redis/client.py", line 1163, in blpop return self.execute_command('BLPOP', *keys) File "/var/www/django/dotaleague.cz/env/lib/python3.5/site-packages/redis/client.py", line 573, in execute_command return self.parse_response(connection, command_name, **options) File "/var/www/django/dotaleague.cz/env/lib/python3.5/site-packages/redis/client.py", line 585, in parse_response response = connection.read_response() File "/var/www/django/dotaleague.cz/env/lib/python3.5/site-packages/redis/connection.py", line 577, in read_response response = self._parser.read_response() File "/var/www/django/dotaleague.cz/env/lib/python3.5/site-packages/redis/connection.py", line 238, in read_response response = self._buffer.readline() File "/var/www/django/dotaleague.cz/env/lib/python3.5/site-packages/redis/connection.py", line 168, in readline self._read_from_socket() File "/var/www/django/dotaleague.cz/env/lib/python3.5/site-packages/redis/connection.py", line 126, in _read_from_socket data = self._sock.recv(socket_read_size) File "/var/www/django/dotaleague.cz/env/lib/python3.5/site-packages/gevent/_socket3.py", line 337, in recv self._wait(self._read_event) File "/var/www/django/dotaleague.cz/env/lib/python3.5/site-packages/gevent/_socket3.py", line 157, in _wait self.hub.wait(watcher) File "/var/www/django/dotaleague.cz/env/lib/python3.5/site-packages/gevent/hub.py", line 651, in wait result = waiter.get() File "/var/www/django/dotaleague.cz/env/lib/python3.5/site-packages/gevent/hub.py", line 899, in get return self.hub.switch() File "/var/www/django/dotaleague.cz/env/lib/python3.5/site-packages/gevent/hub.py", line 630, in switch return RawGreenlet.switch(self) gevent.hub.LoopExit: ('This operation would block forever', <Hub at 0x7f867ae61048 epoll pending=0 ref=0 fileno=26>)

rossengeorgiev commented 7 years ago

This doesn't look like problem with dota2 package. Hard to say what the cause is without seeing the complete code. Gevent might not play with certain packages, as the steam package makes use of the monkeypatching for stdlib.