Skip to content

Greenlet cannot switch to different thread #784

Open
@markf94

Description

@markf94

I'm trying to use progressbar in combination with the AWS API boto3. When downloading a file from AWS S3 a callback can be used to track the progress of the download. When streaming this into progressbar.Progressbar bpython fails on me with the following stacktrace:

  File "/home/markf94/.local/lib/python3.7/site-packages/s3transfer/futures.py", line 106, in result
    return self._coordinator.result()
  File "/home/markf94/.local/lib/python3.7/site-packages/s3transfer/futures.py", line 265, in result
    raise self._exception
  File "/home/markf94/.local/lib/python3.7/site-packages/s3transfer/tasks.py", line 126, in __call__
    return self._execute_main(kwargs)
  File "/home/markf94/.local/lib/python3.7/site-packages/s3transfer/tasks.py", line 150, in _execute_main
    return_value = self._main(**kwargs)
  File "/home/markf94/.local/lib/python3.7/site-packages/s3transfer/download.py", line 523, in _main
    for chunk in chunks:
  File "/home/markf94/.local/lib/python3.7/site-packages/s3transfer/download.py", line 651, in __next__
    chunk = self._body.read(self._chunksize)
  File "/home/markf94/.local/lib/python3.7/site-packages/s3transfer/utils.py", line 546, in read
    invoke_progress_callbacks(self._callbacks, len(value))
  File "/home/markf94/.local/lib/python3.7/site-packages/s3transfer/utils.py", line 141, in invoke_progress_callbacks
    callback(bytes_transferred=bytes_transferred)
  File "/usr/local/lib/python3.7/site-packages/boto3/s3/transfer.py", line 338, in on_progress
    self._callback(bytes_transferred)
  File "/home/markf94/proteinqure/code/platform/warehouse/pq_warehouse/factories.py", line 173, in __call__
    sys.stdout.write('\r' + TERM_UP_ONE_LINE + TERM_CLEAR_LINE)
  File "/usr/lib/python3.7/site-packages/bpython/curtsiesfrontend/coderunner.py", line 220, in write
    return self.coderunner.request_from_main_context(force_refresh=True)
  File "/usr/lib/python3.7/site-packages/bpython/curtsiesfrontend/coderunner.py", line 195, in request_from_main_context
    value = self.main_context.switch(Refresh())
greenlet.error: cannot switch to a different thread

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions