Skip to content

Commit

Permalink
main loops
Browse files Browse the repository at this point in the history
  • Loading branch information
gubser committed Jun 1, 2016
1 parent aa9cfad commit 602f849
Showing 2 changed files with 16 additions and 4 deletions.
16 changes: 14 additions & 2 deletions ptocore/sensor.py
Original file line number Diff line number Diff line change
@@ -4,13 +4,15 @@
from .sensitivity import Sensitivity
from .analyzerstate import AnalyzerState

from time import sleep

class Sensor:
def __init__(self, analyzers_coll: Collection, action_log: Collection):
self.analyzers_state = AnalyzerState(analyzers_coll)
self.action_log = action_log

def check(self):
print("sensor: check for work")
sensing = self.analyzers_state.sensing_analyzers()

for analyzer in sensing:
@@ -35,9 +37,19 @@ def check(self):

# the input types and output types specified in the analyzer are now blocked

if __name__ == "__main__":
def run(self):
# TODO consider using threads
while True:
self.check()
sleep(4)


def main():
mongo = MongoClient("mongodb://curator:ah8NSAdoITjT49M34VqZL3hEczCHjbcz@localhost/analysis")

sens = Sensor(mongo.analysis.analyzers, mongo.analysis.action_log)

sens.check()
sens.run()

if __name__ == "__main__":
main()
4 changes: 2 additions & 2 deletions ptocore/supervisor.py
Original file line number Diff line number Diff line change
@@ -108,7 +108,7 @@ def script_agent_done(self, agent: ScriptAgent, fut: asyncio.Future):

def check_for_work(self):
planned = self.analyzers_state.planned_analyzers()
print("check for work")
print("supervisor: check for work")
for analyzer in planned:
print("planned", analyzer)

@@ -132,8 +132,8 @@ def check_for_work(self):

async def run(self):
while True:
await asyncio.sleep(4)
self.check_for_work()
await asyncio.sleep(4)


def main():

0 comments on commit 602f849

Please sign in to comment.