Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: stoppable background tasks by simple set_stop_event method on tasks #406

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jotelha
Copy link
Contributor

@jotelha jotelha commented Jul 3, 2020

Tasks wrapped into BackgroundTask might run forever (In my particular case, I use background tasks to establish some ssh connection, i.e. for file transfer to remote machines. The ssh connection stays open as long as Fireworks itself runs, even if the connection-dependent file transfer task has finished, blocking the allocated port indefinitely). Give them an opportunity to exit gracefully by suggesting any such task to implement some set_stop_event method and forward the stop event if this method exists. A very simple approach.

@computron
Copy link
Member

Hi,

The initial (default) purpose of a background task was to run a process repeatedly at some interval - e.g., every 60 seconds or so - while the main task was running. For example, you might want to repeatedly check the progress of an output file every 60 seconds and update a secondary database with the result.

If you are using the BackgroundTask to establish an ssh connection, does it still stay running indefinitely if:

  1. You set the num_launches parameter of the BackgroundTask to 1 (the default of 0 means to run it indefinitely)
  2. The code for your background task properly closes the ssh connection upon completion? e.g., uses an explicit close()`` command or uses the with``` syntax?

Note that having some kind of external stop event might still make sense (and maybe we want to make this more official by having it be an explicit parameter of BackgroundTask), but just wanted to probe a little more into the situation first.

@computron computron added the stale Stale/abandoned PRs and issues label Jul 15, 2020
Base automatically changed from master to main March 10, 2021 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Stale/abandoned PRs and issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants