Skip to content

Commit 6434533

Browse files
author
Ram Rachum
committed
Merge branch 'development' of github.com:cool-RR/GarlicSim into development
2 parents dd64f23 + 1c43cbb commit 6434533

File tree

5 files changed

+42
-37
lines changed

5 files changed

+42
-37
lines changed

garlicsim/garlicsim/asynchronous_crunching/crunchers/process_cruncher/process.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ class Process(multiprocessing.Process):
2626
'''The actual system process used by `ProcessCruncher`.'''
2727
# One of the reasons that `Process` is a separate entity from
2828
# `ProcessCruncher` is that because the way the `multiprocessing` module
29-
# works, all arguments to `Process.__init__` must be pickleable, which would
30-
# prevent us from getting the crunching manager as an argument, since it's
31-
# not pickleable.
29+
# works, all arguments to `Process.__init__` must be pickleable, which
30+
# would prevent us from getting the crunching manager as an argument, since
31+
# it's not pickleable.
3232

33-
def __init__(self, step_iterator_getter, initial_state, crunching_profile):
33+
def __init__(self, step_iterator_getter, initial_state, crunching_profile):
3434
multiprocessing.Process.__init__(self)
3535

3636
self.step_iterator_getter = step_iterator_getter
@@ -89,10 +89,10 @@ def run(self):
8989
Internal method.
9090
9191
This is called when the cruncher is started. It just calls the
92-
`main_loop` method in a try clause, excepting `ObsoleteCruncherException`;
93-
That exception means that the cruncher has been retired in the middle of
94-
its job, so it is propagated up to this level, where it causes the
95-
cruncher to terminate.
92+
`main_loop` method in a try clause, excepting
93+
`ObsoleteCruncherException`; That exception means that the cruncher has
94+
been retired in the middle of its job, so it is propagated up to this
95+
level, where it causes the cruncher to terminate.
9696
'''
9797
try:
9898
self.main_loop()
@@ -159,8 +159,9 @@ def check_crunching_profile(self, state):
159159
we retire the cruncher.
160160
'''
161161
if self.crunching_profile.state_satisfies(state):
162-
raise ObsoleteCruncherException("We're done working, the clock target "
163-
"has been reached. Shutting down.")
162+
raise ObsoleteCruncherException("We're done working, the clock "
163+
"target has been reached. "
164+
"Shutting down.")
164165

165166

166167
def get_order(self):
@@ -179,8 +180,8 @@ def process_order(self, order):
179180
'''Process an order receieved from `.order_queue`.'''
180181

181182
if order == 'retire':
182-
raise ObsoleteCruncherException("Cruncher received a 'retire' order; "
183-
"Shutting down.")
183+
raise ObsoleteCruncherException("Cruncher received a 'retire' "
184+
"order; Shutting down.")
184185

185186
elif isinstance(order, CrunchingProfile):
186187
self.process_crunching_profile_order(order)
@@ -190,7 +191,7 @@ def process_order(self, order):
190191
def process_crunching_profile_order(self, order):
191192
'''Process an order to update the crunching profile.'''
192193
if self.crunching_profile.step_profile != order.step_profile:
193-
raise ObsoleteCruncherException('Step profile changed; shutting down. '
194-
'Crunching manager should create a '
195-
'new cruncher.')
194+
raise ObsoleteCruncherException('Step profile changed; shutting '
195+
'down. Crunching manager should '
196+
'create a new cruncher.')
196197
self.crunching_profile = order

garlicsim/garlicsim/asynchronous_crunching/crunchers/process_cruncher/process_cruncher.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,10 @@ class ProcessCruncher(BaseCruncher):
4141
Read more about crunchers in the documentation of the `crunchers` package.
4242
4343
The advantage of `ProcessCruncher` over `ThreadCruncher` is that
44-
`ProcessCruncher` is able to run on a different core of the processor in the
45-
machine, thus using the full power of the processor.
44+
`ProcessCruncher` is able to run on a different core of the processor in
45+
the machine, thus using the full power of the processor.
4646
'''
4747

48-
4948
gui_explanation = string_tools.docstring_trim(
5049
'''
5150
`ProcessCruncher`:
@@ -94,9 +93,9 @@ def can_be_used_with_simpack_grokker(simpack_grokker):
9493
'''
9594
Return whether `ProcessCruncher` can be used with `simpack_grokker`.
9695
97-
For `ProcessCruncher` to be usable, the `multiprocessing` module must be
98-
installed. Assuming it's installed, `ProcessCruncher` can be used if and
99-
only if the simpack is not history-dependent.
96+
For `ProcessCruncher` to be usable, the `multiprocessing` module must
97+
be installed. Assuming it's installed, `ProcessCruncher` can be used if
98+
and only if the simpack is not history-dependent.
10099
'''
101100

102101
if not import_tools.exists('multiprocessing'):

garlicsim/garlicsim/asynchronous_crunching/crunchers/thread_cruncher.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,10 @@ class ThreadCruncher(threading.Thread, BaseCruncher):
6060
6161
- Easy to debug.
6262
63-
- On a single-core computer, it may be faster than `ProcessCruncher` because
64-
of shared memory.
65-
'''
63+
- On a single-core computer, it may be faster than `ProcessCruncher`\
64+
because of shared memory.
65+
66+
'''
6667
)
6768

6869

@@ -107,10 +108,10 @@ def run(self):
107108
Internal method.
108109
109110
This is called when the cruncher is started. It just calls the
110-
`main_loop` method in a `try` clause, excepting `ObsoleteCruncherException`;
111-
That exception means that the cruncher has been retired in the middle of
112-
its job, so it is propagated up to this level, where it causes the
113-
cruncher to terminate.
111+
`main_loop` method in a `try` clause, excepting
112+
`ObsoleteCruncherException`; That exception means that the cruncher has
113+
been retired in the middle of its job, so it is propagated up to this
114+
level, where it causes the cruncher to terminate.
114115
'''
115116
try:
116117
self.main_loop()
@@ -179,8 +180,9 @@ def check_crunching_profile(self, state):
179180
we retire the cruncher.
180181
'''
181182
if self.crunching_profile.state_satisfies(state):
182-
raise ObsoleteCruncherException("We're done working, the clock target "
183-
"has been reached. Shutting down.")
183+
raise ObsoleteCruncherException("We're done working, the clock "
184+
"target has been reached. "
185+
"Shutting down.")
184186

185187

186188
def get_order(self):
@@ -198,8 +200,8 @@ def get_order(self):
198200
def process_order(self, order):
199201
'''Process an order receieved from `.order_queue`.'''
200202
if order == 'retire':
201-
raise ObsoleteCruncherException("Cruncher received a 'retire' order; "
202-
"Shutting down.")
203+
raise ObsoleteCruncherException("Cruncher received a 'retire' "
204+
"order; Shutting down.")
203205

204206
elif isinstance(order, CrunchingProfile):
205207
self.process_crunching_profile_order(order)
@@ -208,9 +210,9 @@ def process_order(self, order):
208210
def process_crunching_profile_order(self, order):
209211
'''Process an order to update the crunching profile.'''
210212
if self.crunching_profile.step_profile != order.step_profile:
211-
raise ObsoleteCruncherException('Step profile changed; shutting down. '
212-
'Crunching manager should create a '
213-
'new cruncher.')
213+
raise ObsoleteCruncherException('Step profile changed; shutting '
214+
'down. Crunching manager should '
215+
'create a new cruncher.')
214216
self.crunching_profile = order
215217

216218

garlicsim/garlicsim/general_misc/persistent/human_names/female.txt

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

garlicsim/garlicsim/general_misc/persistent/personality.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ def __init__(self, persistent):
3737

3838
u = int(persistent._CrossProcessPersistent__uuid)
3939

40-
(u, human_name_seed) = divmod(u, 5494)
40+
(u, human_name_seed) = divmod(
41+
u,
42+
len(human_names.name_list)
43+
)
4144
self.human_name = human_names.name_list[human_name_seed]
4245
'''A human name. (e.g. "Jeffrey".)'''
4346

0 commit comments

Comments
 (0)