Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • Trac Trac
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Issues 246
    • Issues 246
    • List
    • Boards
    • Service Desk
    • Milestones
  • Monitor
    • Monitor
    • Metrics
    • Incidents
  • Analytics
    • Analytics
    • Value stream
  • Wiki
    • Wiki
  • Activity
  • Create a new issue
  • Issue Boards
Collapse sidebar
  • Legacy
  • TracTrac
  • Issues
  • #17946
Closed
Open
Created Dec 29, 2015 by Trac@tracbot

launch_tor should kill process on exception while bootstrapping (for example, on KeyboardInterrupt)

What will happen if we will call

stem.process.launch_tor_with_config(config, timeout=None)

and CTRL+C some time after?

KeyboardInterrupt exception would be raised somewhere inside launch_tor, and we will have one of following situations:

  1. KeyboardInterrupt raised before or while subprocess.Popen - everything is ok
  2. KeyboardInterrupt raised after subprocess.Popen, inside bootstrapping, but before launch_tor finished - we will have hanging tor process with no ability to terminate it manually.

This issue is about to fix second case. All we need is to add handling of second situation inside launch_tor function. Here's example of code that should be added before line 165 inside stem.process:

except:  # on any exception while bootstrapping
    tor_process.kill()  # kill existing process
    raise  # reraise exception

But note, you should also fix "finally" block to prevent closing stdout, stderr of terminated process.

Note, this issue is not only about KeyboardInterrupt, but also for any other exception that can be raised suddenly everyehere, like asyncio.CancelledError

Trac:
Username: germn

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking