Opened 3 years ago

Closed 3 years ago

#13141 closed defect (fixed)

Stem : Too many open file error

Reported by: RSenet Owned by: atagar
Priority: Medium Milestone: Tor: unspecified
Component: Core Tor/Stem Version: Tor: unspecified
Severity: Keywords: Stem, python, tor, too many open file
Cc: Actual Points:
Parent ID: Points:
Reviewer: Sponsor:

Description

If you launch many connection over Tor using stem and launch_tor_with_config function, you'll probably have an exception like :
OSError: [Errno 24] Too many open files

The problem is comming from this line:
torrc_path = tempfile.mkstemp(prefix = "torrc-", text = True)[1]

This exception is raise because "tempfile.mkstemp" create a file descriptor which is never closed in process.py file.

To properly close tempile, you have to use this correction :
fileDescriptor, torrc_path = tempfile.mkstemp(prefix = 'torrc-', text = True)

Before delete the temp file, you just have to close the file descriptor:
os.close(fileDescriptor)

Child Tickets

Change History (2)

comment:2 Changed 3 years ago by atagar

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.