Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_generator(self):
def _gen(n):
while (n > 0):
yield n
n -= 1
yappi.start()
for x in _gen(5):
pass
self.assertTrue(
yappi.convert2pstats(yappi.get_func_stats()) is not None
)
def finish(self):
from gi.repository import Gtk
if self.debug:
import yappi
yappi.stop()
yappi.convert2pstats(yappi.get_func_stats()).dump_stats(
'mfp-gui-funcstats.pstats')
log.log_func = None
if self.appwin:
self.appwin.quit()
self.appwin = None
Gtk.main_quit()
monitoring_gil = True
except (RuntimeError, ImportError):
monitoring_gil = False
pass
yappi.start()
yield
yappi.stop()
if monitoring_gil:
gil_load.stop()
stats = gil_load.get()
print("GIL load information: ",
gil_load.format(stats))
p = yappi.get_func_stats()
p = yappi.convert2pstats(p)
p.dump_stats(filename)
yappi.clear_stats()
filename = '/g/data/u46/gxr547/%s_%s_%s'%(lon, lat, dt)
data = []
for yidx, yoff in enumerate(range(0, 4000, N)):
kwargs = dict(y=slice(yoff, yoff+N), t=Range(dt, dt+numpy.timedelta64(1, 'Y')))
r = dask.imperative.do(do_work)(stack, pqa, qs, **kwargs)
data.append(r)
for qidx, q in enumerate(qs):
r = dask.imperative.do(write_file)(filename + '_' + str(q) + '.tif', data, qidx, N, geotr, proj)
tasks.append(r)
#executor = Executor('127.0.0.1:8787')
#dask.imperative.compute(tasks, get=executor.get)
dask.imperative.compute(tasks, get=dask.multiprocessing.get, num_workers=num_workers)
yappi.convert2pstats(yappi.get_func_stats()).dump_stats('dask_mp.lprof')
# allow session management
app.session_management_setup()
try:
QuittableThread.wait_for_all()
except (KeyboardInterrupt, SystemExit):
log.log_force_console = True
app.finish()
for thread in app.leftover_threads:
thread.join()
if app.debug:
import yappi
yappi.stop()
yappi.convert2pstats(yappi.get_func_stats()).dump_stats('mfp-main-funcstats.pstats')
yappi.start(profile_threads=True)
print("Starting to profile")
thread = threading.Thread(target=activitywatch.start, kwargs={"loglevel": logging.DEBUG}, daemon=False)
thread.start()
try:
sleep(60*60*24) # Sleep for 24h, allowing activitywatch to do work
print("Expired")
except KeyboardInterrupt:
print("Interrupted")
yappi.stop()
print("Computing statistics, please wait...")
p = yappi.convert2pstats(yappi.get_func_stats().get())
p.sort_stats("cumtime")
p.print_stats()