Example #1
0
 def execute(self, runnable):
     runner = Runner(runnable)
     thread = Thread(runner, name='RobotFrameworkTimeoutThread')
     thread.setDaemon(True)
     thread.start()
     thread.join(int(self._timeout * 1000))
     if thread.isAlive():
         thread.stop()
         raise TimeoutError(self._error)
     return runner.get_result()
Example #2
0
 def execute(self, runnable):
     runner = Runner(runnable)
     thread = Thread(runner, name='RobotFrameworkTimeoutThread')
     thread.setDaemon(True)
     thread.start()
     thread.join(int(self._timeout * 1000))
     if thread.isAlive():
         thread.stop()
         raise TimeoutError(self._error)
     return runner.get_result()
Example #3
0
currentLayerPath = os.path.join(os.path.dirname(projectPath), 'currentLayer_' + namePlugin + '.txt')
currentWrittenLayer = fc.incrementCounter(currentLayerPath, increment = nLayersAtATime)
l = AtomicInteger(currentWrittenLayer)

# fc.startThreads(elasticMontage(), wait = 1, nThreads = nThreads) /!\ it does not work I do not understand why. Probably a java6 issue because it works in other scripts in java8 ...

threads = []
for p in range(nThreads):
	thread = Thread(elasticMontage)
	threads.append(thread)
	thread.start()
	time.sleep(0.5)
	
for thread in threads:
	thread.join()


IJ.log( namePlugin + ' layer ' + str(currentWrittenLayer))
fc.resizeDisplay(layerset)
project.save()

IJ.log('Sleeping in case the saving of the large project takes some time ...')
time.sleep(20)

# save all transforms
transformsPath = os.path.join(os.path.dirname(projectPath) , namePlugin + '_Transforms.txt')
if l.get() > nLayers-1:
	fc.writeAllAffineTransforms(project,transformsPath)

fc.shouldRunAgain(namePlugin, currentWrittenLayer, nLayers, MagCFolder, project, increment = nLayersAtATime)
Example #4
0
t1 = MyThread()
t1.start()
t1.join()
assert t1.count == 1, 'subclassing java.lang.Thread'

print_test('pass subclass back to java', 2)

class MyRun(Runnable):
	count = 0
	def run(self):
		self.count = self.count+1

run = MyRun()
t = Thread(run)
t.start()
t.join()
assert run.count == 1, 'subclassing java.lang.Thread'

print_test("invoke super's constructor", 2)

class MyThread(Thread):
	def __init__(self):
		self.name = "Python-"+self.name

t = MyThread()
assert t.name[:14] == "Python-Thread-", 'automatic constructor call'

class MyThread(Thread):
	def __init__(self):
		Thread.__init__(self, "Python-Thread")
Example #5
0
assert t1.count == 1, 'subclassing java.lang.Thread'

print_test('pass subclass back to java', 2)


class MyRun(Runnable):
    count = 0

    def run(self):
        self.count = self.count + 1


run = MyRun()
t = Thread(run)
t.start()
t.join()
assert run.count == 1, 'subclassing java.lang.Thread'

print_test("invoke super's constructor", 2)


class MyThread(Thread):
    def __init__(self):
        self.name = "Python-" + self.name


t = MyThread()
assert t.name[:14] == "Python-Thread-", 'automatic constructor call'


class MyThread(Thread):
Example #6
0
    import datetime
    from strategies import random_signal_combos_generator, Strategy
    from signals import available_signals

    definition = {"symbol": "ES", "secType": "FUT", "expiry": "200712", "exchange": "GLOBEX", "currency": "USD"}
    signal_combos = random_signal_combos_generator(available_signals, 50)
    start_time = datetime.time(9, 30)  # times for the test data
    end_time = datetime.time(15, 45)  # should exit after this
    strategies = [Strategy(signals=combo, start=start_time, end=end_time) for combo in signal_combos]
    split = len(strategies) / 2  # divide over tasks
    start = datetime.datetime.now()
    t1 = Thread(TestRunner(1, definition, strategies[:split]))
    t1.start()
    t2 = Thread(TestRunner(2, definition, strategies[split:]))
    t2.start()
    t1.join()  # join here after t1 has finished
    t2.join()  # join here after t2 has finished
    end = datetime.datetime.now()
    print "finished crunching %s strategies, time: %s, %s seconds per " "strategy" % (
        len(strategies),
        str(end - start),
        round((end - start).seconds * 1.0 / len(strategies), 2),
    )

    for sss in strategies:
        rp = sss.report
        print rp["result_for_capacity_percentage"], rp["long_trades"], rp["short_trades"], rp[
            "sum_all_results_with_commission"
        ]
        print sss.signals