Skip to content

Commit

Permalink
fix threads.py example by adding gc.collect() (#44)
Browse files Browse the repository at this point in the history
Co-authored-by: Sang woo Ham <sham@lbl.gov>
  • Loading branch information
ecosang and sangwooham committed Apr 11, 2023
1 parent 5183955 commit 39ab2c6
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion examples/threads.py
@@ -1,7 +1,7 @@
import sat
import sys
import threading

import gc
# At present, GLPK itself, and consequently PyGLPK, are not thread
# safe. As a result, this "multithreaded" example at present does not
# run the threads in parallel during solving. I am, however,
Expand All @@ -13,6 +13,7 @@
def solve_problem(tid, num):
exp = sat.generate_cnf(vars, clauses)
assignment = sat.solve_sat(exp)
gc.collect()
if assignment: assert sat.verify(exp, assignment)
sys.stdout.write((('+' if assignment else '-')+'(%d,%2d)')%(tid,num))
sys.stdout.flush()
Expand Down

0 comments on commit 39ab2c6

Please sign in to comment.