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

Occasional InvalidStateError #43

Open
vegeta1k95 opened this issue Nov 8, 2020 · 0 comments
Open

Occasional InvalidStateError #43

vegeta1k95 opened this issue Nov 8, 2020 · 0 comments

Comments

@vegeta1k95
Copy link

vegeta1k95 commented Nov 8, 2020

If I put in a loop a function which creates a Thread which connects to proxy (one proxie at each iteration) and disconnects immediately, sometimes I get errors like this:

Exception in callback Future.set_result(True)
handle: <Handle Future.set_result(True) created at D:\!_Work\Python38\lib\site-packages\aiosocks\protocols.py:92>
source_traceback: Object created at (most recent call last):
  File "D:\!_Work\Python38\lib\concurrent\futures\thread.py", line 80, in _worker
    work_item.run()
  File "D:\!_Work\Python38\lib\concurrent\futures\thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "D:\!_Work\Python38\lib\asyncio\runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "D:\!_Work\Python38\lib\asyncio\base_events.py", line 603, in run_until_complete
    self.run_forever()
  File "D:\!_Work\Python38\lib\asyncio\base_events.py", line 570, in run_forever
    self._run_once()
  File "D:\!_Work\Python38\lib\asyncio\base_events.py", line 1851, in _run_once
    handle._run()
  File "D:\!_Work\Python38\lib\asyncio\events.py", line 81, in _run
    self._context.run(self._callback, *self._args)
  File "D:\!_Work\Python38\lib\site-packages\aiosocks\protocols.py", line 92, in negotiate
    self._loop.call_soon(self._waiter.set_result, True)
Traceback (most recent call last):
  File "D:\!_Work\Python38\lib\asyncio\events.py", line 81, in _run
    self._context.run(self._callback, *self._args)
asyncio.exceptions.InvalidStateError: invalid state

For some reason, _waiter is already cancelled when we are trying to set result to it, which lead to error.

@vegeta1k95 vegeta1k95 changed the title InvalidStateError in Occasional InvalidStateError Nov 8, 2020
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

1 participant