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.

Fatal Python error: could not acquire lock at interpreter shutdown...

See original GitHub issue

A little bit excited about this project :)

In the process playing around, and have been getting some odd results with the following program:

# main.py
from chopsticks.tunnel import Tunnel
import tasks

def main(host):
    host.call(tasks.get_time)

if __name__ == '__main__':
    main(Tunnel('user@example.com'))

# tasks.py
import subprocess

def get_time():
    return subprocess.run('time', stdout=subprocess.PIPE, shell=True).stdout.decode()
  • Sometimes nothing prints, and program exits with code 0.
  • Sometimes I get the following (expected) printout (and code 0):
    [user@example.com] Usage: time [-apvV] [-f format] [-o file] [--append] [--verbose]
    [user@example.com]        [--portability] [--format=format] [--output=file] [--version]
    [user@example.com]        [--quiet] [--help] command [arg...]
    
  • … and sometimes I get a total failure:
[user@example.com] Usage: time [-apvV] [-f format] [-o file] [--append] [--verbose]
Fatal Python error: could not acquire lock for <_io.BufferedWriter name='<stderr>'>
at interpreter shutdown, possibly due to daemon threads

Thread 0x00007f86dde4c700 (most recent call first):
  File ".../lib/python3.6/site-packages/chopsticks/ioloop.py", line 155 in println
  File ".../lib/python3.6/site-packages/chopsticks/ioloop.py", line 162 in _check
  File ".../lib/python3.6/site-packages/chopsticks/ioloop.py", line 145 in on_data
  File ".../lib/python3.6/site-packages/chopsticks/ioloop.py", line 223 in step
  File ".../lib/python3.6/site-packages/chopsticks/ioloop.py", line 242 in run
  File "/usr/lib64/python3.6/threading.py", line 864 in run
  File "/usr/lib64/python3.6/threading.py", line 916 in _bootstrap_inner
  File "/usr/lib64/python3.6/threading.py", line 884 in _bootstrap

Current thread 0x00007f86e259c4c0 (most recent call first):
[1]    6661 abort (core dumped)  ./main.py

The number of lines that successfully print before failure varies.


I’m running Python 3.6.1 locally, and 3.5.2 on the server. I don’t know if it helps, but the result of running ssh -V is OpenSSH_7.5p1, OpenSSL 1.1.0f 25 May 2017.

Please let me know if there’s any further information I could provide to help shed some light on this.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
lordmauvecommented, Jul 2, 2017

Thanks. I’ll open an issue about the stderr handling specifically.

0reactions
meshycommented, Jul 2, 2017

I’ve just had another look. I was indeed using chopsticks 0.5, and it works on master \o/.

I’ve done a bisect, and it looks as though it was fixed in 41d7683da300e2a0f88a3a46add0eb49b3f54fce.

Thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fatal Python error: could not acquire lock for <_io ... - GitHub
It's probably related to Python trying to exit while the reader is not done - the generator will not be finished and may...
Read more >
How to fix a 'fatal Python error: _enter_buffered_busy
How to fix a 'fatal Python error: _enter_buffered_busy: could not aquire lock for <_io.BufferedWriter name='<stdout>'> at interpreter shutdown' ...
Read more >
The python interpreter crashed with "_enter_buffered_busy"
My knowledge isn't complete here, but something similar to: * During shutdown, the daemon threads are aborted * In your example, the thread...
Read more >
What are possible causes of this interpreter error? - Reddit
Fatal Python error: could not acquire lock for <_io.BufferedWriter name='<stdout>'> at interpreter shutdown, possibly due to daemon threads.
Read more >
Output console doesn't release stdin lock before finalization
Fatal Python error : could not acquire lock for <_io.BufferedReader name='<stdin>'> at interpreter shutdown, possibly due to daemon threads Python runtime ...
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