Skip to content

Instantly share code, notes, and snippets.

View lfdversluis's full-sized avatar

Laurens Versluis lfdversluis

View GitHub Profile
@lfdversluis
lfdversluis / gist:00b27126b9eb0ef4c89101198463ceae
Created August 14, 2016 13:23
2016-08-14 Dispersy empty state dir query output
------- commit --------
Times called: 69
total time: 2.758 seconds
avg: 0.03998
min: 0.00000
max: 0.21891
Total amount of functions calling this db function: 10
Top 5 callers issuing the heaviest query:
(218 ms) Function _flush_database at /home/tribler/Documents/tribler/Tribler/dispersy/dispersy.py line 2089
(204 ms) Function _flush_database at /home/tribler/Documents/tribler/Tribler/dispersy/dispersy.py line 2089
@lfdversluis
lfdversluis / gist:5c49ec6dcc73cc20f1b690c9d174229c
Created August 14, 2016 13:18
2016-08-14 tribler sync db stuff
------- fetchall --------
Times called: 91661
total time: 278.319 seconds
avg: 0.00304
min: 0.00000
max: 0.23420
Total amount of functions calling this db function: 20
Top 5 callers issuing the heaviest query:
(234 ms) Function getRecentAndRandomTorrents at /home/tribler/Documents/tribler/Tribler/Core/CacheDB/SqliteCacheDBHandler.py line 1846
(208 ms) Function getPeerIDS at /home/tribler/Documents/tribler/Tribler/Core/CacheDB/SqliteCacheDBHandler.py line 101
from time import sleep
from twisted.internet import reactor
from twisted.internet.defer import inlineCallbacks
from twisted.internet.task import deferLater
@inlineCallbacks
def a():
yield deferLater(reactor, 1, lambda: None) # Now the blocking function is made async, we need to yield it.
@lfdversluis
lfdversluis / test.py
Created June 15, 2016 09:07
Test does not raise on yield but "???" prints
from unittest import TestCase
from nose.tools import raises
from nose.twistedtools import reactor
from twisted.internet.defer import inlineCallbacks
from twisted.internet.threads import blockingCallFromThread
class TestExample(TestCase):
@inlineCallbacks
@raises(RuntimeError)
@lfdversluis
lfdversluis / test.py
Created June 9, 2016 11:15
Ardhi test example fix
deferred(timeout=20)
def test_save_resume(self):
tdef = TorrentDef()
sourcefn = os.path.join(TESTS_DATA_DIR, 'video.avi')
tdef.add_content(sourcefn)
tdef.set_tracker("http://localhost/announce")
tdef.finalize()
torrentfn = os.path.join(self.session.get_state_dir(), "gen.torrent")
tdef.save(torrentfn)
@lfdversluis
lfdversluis / gist:855038617d767dc4b72086dae8f9b462
Created May 20, 2016 08:51
python twisted failure check problem
from twisted.internet.error import ConnectingCancelledError
from twisted.internet.defer import Deferred, CancelledError
# This prints no - it doesn't work
d = Deferred()
def on_error(failure):
if failure.check([ConnectingCancelledError, CancelledError]):
@lfdversluis
lfdversluis / gist:caf23760eeab7d343d67
Created November 25, 2015 12:35
Tribler hidden_community stacktrace
(gdb) bt
#0 __GI___pthread_mutex_lock (mutex=0x7fffffff5c20)
at ../nptl/pthread_mutex_lock.c:66
#1 0x00007fffebb020da in XrmQGetResource ()
from /usr/lib/x86_64-linux-gnu/libX11.so.6
#2 0x00007fffebadfa42 in XGetDefault ()
from /usr/lib/x86_64-linux-gnu/libX11.so.6
#3 0x00007fffeb42034f in ?? () from /usr/lib/x86_64-linux-gnu/libcairo.so.2
#4 0x00007fffeb422690 in ?? () from /usr/lib/x86_64-linux-gnu/libcairo.so.2