question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Interpreter doesn't exist if s3 object is not closed

See original GitHub issue

I have this absolutely minimal program:

import s3fs
s3 = s3fs.S3FileSystem().open("bucket/file", "wb")
print("END")

Taking a look at this, I would expect that if you start it with python program.py, it will print an END and exit. Instead it prints END and never exits. If I put an s3.close() it works as expected.

Printing a stack trace after print gives:

Current thread 0x00007f102cfc2740 (most recent call first):
  File "/usr/local/lib/python3.10/threading.py", line 324 in wait
  File "/usr/local/lib/python3.10/threading.py", line 600 in wait
  File "/usr/local/lib/python3.10/site-packages/fsspec/asyn.py", line 59 in sync
  File "/usr/local/lib/python3.10/site-packages/fsspec/asyn.py", line 91 in wrapper
  File "/usr/local/lib/python3.10/site-packages/s3fs/core.py", line 1970 in commit
  File "/usr/local/lib/python3.10/site-packages/s3fs/core.py", line 1961 in _upload_chunk
  File "/usr/local/lib/python3.10/site-packages/fsspec/spec.py", line 1522 in flush
  File "/usr/local/lib/python3.10/site-packages/fsspec/spec.py", line 1651 in close
  File "/usr/local/lib/python3.10/site-packages/fsspec/spec.py", line 1673 in __del__

Packages:

$ pip freeze
aiobotocore==2.0.1
aiohttp==3.8.1
aioitertools==0.8.0
aiosignal==1.2.0
async-timeout==4.0.2
attrs==21.2.0
botocore==1.22.8
charset-normalizer==2.0.9
frozenlist==1.2.0
fsspec==2021.11.1
idna==3.3
jmespath==0.10.0
multidict==5.2.0
python-dateutil==2.8.2
s3fs==2021.11.1
six==1.16.0
urllib3==1.26.7
wrapt==1.13.3
yarl==1.7.2
$ python -V
Python 3.10.1

(but it fails with older python and module versions as well, for eg. we run 2021.8.1 in prod)

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
martindurantcommented, Dec 20, 2021

btw: I regularly get hangs on exit in many python multi-threaded or async applications, needing a ^C to exit.

1reaction
martindurantcommented, Dec 20, 2021

this is not in line with how other file-like objects work

Actually, it is - you stand to loose data if you exit a python program without closing files first. OK, you won’t get a hang. The trouble is, that finalizing a file might well take some time (flushing a buffer to remote), so we can’t very well just add a timeout. The best we can do is check if the event-loop/thread/client are still alive, but I’m not sure this is enough. @efiop , since you were just looking at async, you might have an idea?

Again, I’m not sure how/if we can fix this for sure - but a program trying to exit on an exception if going to be problematic in many cases.

Read more comments on GitHub >

github_iconTop Results From Across the Web

AWS throws the following error: "bad interpreter: No such file ...
Option 1. Type brew uninstall awscli. Then brew install awscli. update python to 3.9. look in the following post. If this approach does...
Read more >
Troubleshooting AWS CodeBuild
The service role being used by CodeBuild does not have s3:GetObject and s3:PutObject permissions to the S3 bucket that is holding the cache....
Read more >
An Introduction to R - The Comprehensive R Archive Network
An Introduction to R. This is an introduction to R (“GNU S”), a language and environment for statistical computing and graphics. R is...
Read more >
Translate — Boto3 Docs 1.26.36 documentation - AWS
The URI of the S3 folder that contains a translation job's output file. ... It does not include characters that are used to...
Read more >
Exceptions and debugging - Advanced R. - Hadley Wickham
I have provided an R translation of the chapter at ... RStudio currently does not support conditional breakpoints, whereas you can always put...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found