This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(gdb) bt | |
#0 0x0000555555555f3b in readcb () | |
#1 0x00007ffff7983e32 in ?? () from /usr/lib/x86_64-linux-gnu/libevent-2.1.so.6 | |
#2 0x00007ffff79898f8 in ?? () from /usr/lib/x86_64-linux-gnu/libevent-2.1.so.6 | |
#3 0x00007ffff798a33f in event_base_loop () from /usr/lib/x86_64-linux-gnu/libevent-2.1.so.6 | |
#4 0x00005555555568ff in _init_event_loop () | |
#5 0x0000555555556527 in proxy () | |
#6 0x00005555555563f4 in main () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(gdb) bt | |
#0 0x00005555555559aa in do_accept () | |
#1 0x00007ffff79898f8 in ?? () from /usr/lib/x86_64-linux-gnu/libevent-2.1.so.6 | |
#2 0x00007ffff798a33f in event_base_loop () from /usr/lib/x86_64-linux-gnu/libevent-2.1.so.6 | |
#3 0x000055555555697a in _init_event_loop () | |
#4 0x00005555555565a2 in proxy () | |
#5 0x000055555555646f in main () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ python -m memory_profiler mysql.py | |
Filename: mysql.py | |
Line # Mem usage Increment Line Contents | |
================================================ | |
4 19.375 MiB 19.375 MiB @profile | |
... | |
7 19.742 MiB 0.367 MiB connection = pymysql.connect(...) | |
... | |
13 19.742 MiB 0.000 MiB connection.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! encoding: utf-8 | |
"""Apparently gevent doesn't switch when writing to files on disk.""" | |
from __future__ import print_function | |
import gevent | |
from gevent import monkey | |
from gevent.fileobject import FileObject | |
monkey.patch_all() | |
import socket | |
import tempfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ python late_patch.py | |
sleep(seconds) | |
Delay execution for a given number of seconds. The argument may be | |
a floating point number for subsecond precision. | |
$ python eager_patch.py | |
Put the current greenlet to sleep for at least *seconds*. | |
*seconds* may be specified as an integer, or a float if fractional |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import print_function | |
from gevent.monkey import patch_all | |
patch_all() | |
from time import sleep | |
print(sleep.__doc__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import print_function | |
from time import sleep | |
from gevent.monkey import patch_all | |
patch_all() | |
print(sleep.__doc__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Usage: start `nc -l 127.0.0.1 8080`, then run this script.""" | |
from __future__ import print_function | |
import socket | |
import time | |
if __name__ == '__main__': | |
n1 = time.clock() | |
n2 = time.time() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def _callback(event, args): | |
# switch and throw both switch the active greenlet from origin to target | |
if event not in set(['switch', 'throw']): | |
return | |
origin, target = args | |
# record last switch (time and CPU tick) | |
global __last_switch_time_ms, __last_switch_cpu_tick |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pip-tools example | |
requests~=2.10 | |
# Pipfile example | |
[packages] | |
requests = '~=2.10' |
NewerOlder