Skip to content

Instantly share code, notes, and snippets.

Avatar

Laurens Versluis lfdversluis

View GitHub Profile
@lfdversluis
lfdversluis / gist:00b27126b9eb0ef4c89101198463ceae
Created Aug 14, 2016
2016-08-14 Dispersy empty state dir query output
View gist:00b27126b9eb0ef4c89101198463ceae
------- 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
View gist:5c49ec6dcc73cc20f1b690c9d174229c
------- 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
@lfdversluis
lfdversluis / test.py
Created Jun 16, 2016
Generators with @inlineCallbacks?
View test.py
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 Jun 15, 2016
Test does not raise on yield but "???" prints
View test.py
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 Jun 9, 2016
Ardhi test example fix
View test.py
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
python twisted failure check problem
View gist:855038617d767dc4b72086dae8f9b462
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 Nov 25, 2015
Tribler hidden_community stacktrace
View gist:caf23760eeab7d343d67
(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
You can’t perform that action at this time.