Skip to content

['receives_statistic_last_second'] dict is changing size during iteration. #37

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

Closed
fsteckel opened this issue Feb 11, 2020 · 12 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@fsteckel
Copy link

Hi, great library.
I report a bug. python version 3.7.5, pip 18.1, ubuntu 19.10 in a local docker container.

After some days my streams encounter exceptions in threads I suspect the unicorn binance manager spawned:
Exception in thread Thread-1816: Traceback (most recent call last): File "/usr/lib/python3.7/threading.py", line 926, in _bootstrap_inner self.run() File "/usr/lib/python3.7/threading.py", line 870, in run self._target(*self._args, **self._kwargs) File "/usr/local/lib/python3.7/dist-packages/unicorn_binance_websocket_api/unicorn_binance_websocket_api_manager.py", line 301, in _frequent_checks for timestamp_key in self.stream_list[stream_id]['receives_statistic_last_second']['entries']: RuntimeError: dictionary changed size during iteration
This happened after I inserted a regular check for binance_websocket_api_manager.get_stream_info(stream_id).
Any idea what might cause this? The ['receives_statistic_last_second'] dict seems to be read by a thread while another is reading it. Do I need to do something before triggering the get_stream_info method?

Cheers

Florian

@oliver-zehentleitner
Copy link
Member

hi Florian!

Thanks for the report! No its not on you to solve this. I must make the section in get_stream_info() thread safe or a deepcopy ... depends on the exact reason whats happening.

I am preparing a new release with subscribe/unsubscribe methods for all endpoints (cex and dex) and i can fix this issue too.

I post you a message when its ready!

Best regards,
Oliver

@oliver-zehentleitner oliver-zehentleitner self-assigned this Feb 11, 2020
@oliver-zehentleitner oliver-zehentleitner added the bug Something isn't working label Feb 11, 2020
@oliver-zehentleitner oliver-zehentleitner added this to the 1.10.0 milestone Feb 11, 2020
@oliver-zehentleitner
Copy link
Member

One question: Which version of the library are you using? 1.9.1 or the dev-stage?

@fsteckel
Copy link
Author

Hey, thanks for the swift reply.
I am using version 1.9.1. I do not quite understand the fix. This line (an the following ones) look exactly like this in the lib.

@oliver-zehentleitner
Copy link
Member

Hello!
Its not fixed, i just set a reminder for me :)
When i release the 1.10.0 this fix will be included!
LG nach Berlin ;)

@oliver-zehentleitner
Copy link
Member

Its fixed now:
https://pypi.org/project/unicorn-binance-websocket-api/
https://github.com/oliver-zehentleitner/unicorn-binance-websocket-api/releases/latest

Please reopen if you still experience this issue!

Best regards!

@fsteckel
Copy link
Author

Great, thanks for the support!

Leiwand! Danke vielmals!

@fsteckel
Copy link
Author

fsteckel commented Feb 15, 2020

Sadly it also happens with the new deepcopy changes:
Traceback (most recent call last): File "/usr/lib/python3.7/threading.py", line 926, in _bootstrap_inner self.run() File "/usr/lib/python3.7/threading.py", line 870, in run self._target(*self._args, **self._kwargs) File "/usr/local/lib/python3.7/dist-packages/unicorn_binance_websocket_api/unicorn_binance_websocket_api_manager.py", line 292, in _freque nt_checks temp_entries = copy.deepcopy(self.stream_list[stream_id]['receives_statistic_last_second']['entries']) File "/usr/lib/python3.7/copy.py", line 150, in deepcopy y = copier(x, memo) File "/usr/lib/python3.7/copy.py", line 239, in _deepcopy_dict for key, value in x.items(): RuntimeError: dictionary changed size during iteration
I seem to not be able to reopen. Request reopening.
Danke :)

@oliver-zehentleitner
Copy link
Member

oliver-zehentleitner commented Feb 15, 2020 via email

@oliver-zehentleitner
Copy link
Member

i added locking now in the dev stage!

can you test it with this installation:
https://github.com/oliver-zehentleitner/unicorn-binance-websocket-api#from-the-latest-source-dev-stage-with-pip-from-github

@oliver-zehentleitner
Copy link
Member

the "solution" triggers a new error ...

oliver-zehentleitner added a commit that referenced this issue Feb 19, 2020
@oliver-zehentleitner
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants