Skip to content

Instantly share code, notes, and snippets.

@bovine
Created November 11, 2016 18:20
Show Gist options
  • Save bovine/47d5b36d614dfc42af8ed4cddda121fe to your computer and use it in GitHub Desktop.
Save bovine/47d5b36d614dfc42af8ed4cddda121fe to your computer and use it in GitHub Desktop.
tpool::post hangs if the maximum number of workers has already been reached, but they have all exited already
#!/usr/local/bin/tclsh
package require Thread
# initialize the thread pool
set mypool [tpool::create -minworkers 1 -maxworkers 5]
# queue up something that exits the thread.
# this will be unable to process more than 5 events because all of the workers have gone away.
for {set i 0} {$i < 10} {incr i} {
tpool::post $mypool "puts \"hello $i\"; thread::exit"
}
tpool::release $mypool
@bovine
Copy link
Author

bovine commented Nov 11, 2016

admittedly, using thread::exit within a tpool is not a normal or recommended activity, but maybe this should be handled and detected better.

@bovine
Copy link
Author

bovine commented Nov 11, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment