Skip to content

Commit 9eb995a

Browse files
author
Ram Rachum
committed
Dizzy... I want mommy.
1 parent aba977c commit 9eb995a

File tree

6 files changed

+60
-6
lines changed

6 files changed

+60
-6
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
*.pyc
1+
*.pyc
2+
*.wpu

garlicsim.wpr

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!wing
2+
#!version=3.0
3+
##################################################################
4+
# Wing IDE project file #
5+
##################################################################
6+
[project attributes]
7+
proj.directory-list = [{'dirloc': loc('.'),
8+
'excludes': (),
9+
'filter': '*',
10+
'include_hidden': False,
11+
'recursive': True,
12+
'watch_for_changes': True}]
13+
proj.file-type = 'shared'

src/garlicsim/project.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
from misc.dumpqueue import dump_queue
2424
from misc.infinity import Infinity # Same as Infinity=float("inf")
2525

26+
PreferredCruncher = CruncherProcess
27+
2628

2729
class Project(object):
2830
"""
@@ -47,8 +49,14 @@ class Project(object):
4749
def __init__(self,simulation_package):
4850

4951
self.init_simulation_package(simulation_package)
52+
5053
self.tree=state.Tree()
5154

55+
if self.history_looker:
56+
self.Cruncher = CruncherThread
57+
else:
58+
self.Cruncher = PreferredCruncher
59+
5260
self.workers={}
5361
"""
5462
A dict that maps edges that should be worked on to workers.
@@ -152,7 +160,6 @@ def sync_workers(self,temp_infinity_node=None):
152160
Returns the total amount of nodes that were added to the tree.
153161
"""
154162

155-
Cruncher = CruncherThread#random.choice([CruncherThread, CruncherProcess])
156163

157164
my_edges_to_crunch=self.edges_to_crunch.copy()
158165

@@ -224,7 +231,7 @@ def sync_workers(self,temp_infinity_node=None):
224231
else:
225232
# Create worker
226233
if edge.still_in_editing==False:
227-
worker=self.workers[edge]=Cruncher(edge.state,step_function=self.simulation_package.step)
234+
worker=self.workers[edge]=self.Cruncher(edge.state,step_function=self.simulation_package.step)
228235
worker.start()
229236
if edge==temp_infinity_node:
230237
continuation_of_temp_infinity_node=edge

src/garlicsimwx/applicationwindow.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ def background_stuff(self, e=None):
122122
A function that calls `sync_workers` for all the
123123
open GuiProjects.
124124
"""
125+
print("bg")
125126
for gui_project in self.gui_projects:
126127
gui_project.sync_workers()
127128

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import multiprocessing
2+
3+
BUFFER = 3
4+
"""
5+
This is the minimum number of idle processes that should always be available.
6+
"""
7+
8+
class Process(multiprocessing.Process):
9+
def start(self):
10+
11+
multiprocessing.Process.start(self)
12+
13+
class xProcess(object):
14+
def __init__(self):
15+
pass
16+
17+
def start(self):
18+
self.process = recruit_process()
19+
20+
21+
def f():
22+
print("working...")
23+
for i in xrange(10**8):
24+
pass
25+
print("done.")
26+
27+
def main():
28+
Proc = Process #multiprocessing.Process # Process
29+
p = Proc(target = f)
30+
p.start()
31+
p.join()
32+
print("process joined")
33+
34+
if __name__=="__main__": main()

src/garlicsimwx/simulationpackages/historytest/historytest.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def make_random_state(*args,**kwargs):
1919
return state
2020

2121

22-
def step(history_browser,*args,**kwargs):
22+
def history_step(history_browser,*args,**kwargs):
2323

2424
new_state=garlicsim.state.State()
2525

@@ -31,5 +31,3 @@ def step(history_browser,*args,**kwargs):
3131
else:
3232
new_state.number=888
3333
return new_state
34-
35-
step.history_looker=True

0 commit comments

Comments
 (0)