Skip to content

Commit de6ddb8

Browse files
committed
Got rid of global variables because of MS windows issues.
1 parent 982ac75 commit de6ddb8

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

structure_threader/structure_threader.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def gracious_exit(*args):
4343
sys.exit(0)
4444

4545

46-
def runprogram(wrapped_prog, iterations):
46+
def runprogram(wrapped_prog, iterations, arg):
4747
"""Run each wrapped program job. Return the worker status.
4848
This attribute will be populated with the worker exit code and output file
4949
and returned. The first element is the exit code itself (0 if normal exit
@@ -136,7 +136,7 @@ def runprogram(wrapped_prog, iterations):
136136
return worker_status
137137

138138

139-
def structure_threader(Ks, replicates, threads, wrapped_prog):
139+
def structure_threader(Ks, replicates, threads, wrapped_prog, arg):
140140
"""Do the threading book-keeping to spawn jobs at the asked rate."""
141141

142142
if wrapped_prog != "structure":
@@ -148,7 +148,7 @@ def structure_threader(Ks, replicates, threads, wrapped_prog):
148148

149149
# This allows us to pass partial arguments to a function so we can later
150150
# use it with multiprocessing map().
151-
temp = partial(runprogram, wrapped_prog)
151+
temp = partial(runprogram, wrapped_prog, arg=arg)
152152

153153
# This will automatically create the Pool object, run the jobs and deadlock
154154
# the function while the children processed are being executed. This will
@@ -424,8 +424,6 @@ def argument_parser(args):
424424
def main():
425425
"""Main function, where variables are set and other functions get called
426426
from."""
427-
global arg
428-
global CWD
429427

430428
arg = argument_parser(sys.argv[1:])
431429

@@ -481,7 +479,7 @@ def main():
481479
signal.signal(signal.SIGINT, gracious_exit)
482480

483481
if arg.justplot is False:
484-
structure_threader(Ks, replicates, threads, wrapped_prog)
482+
structure_threader(Ks, replicates, threads, wrapped_prog, arg)
485483

486484
if wrapped_prog == "maverick":
487485
bestk = maverick_merger(arg.outpath, Ks, arg.notests)

0 commit comments

Comments
 (0)