Suppose I have blocking process blocking_process:
import os
os.system('rm -fr /tmp/pipe; mkfifo /tmp/pipe')
print len(open('/tmp/pipe').read())
On Linux, I might check what is it blocking on by doing:
$ strace -p $(pgrep -f blocking_process)
| def parse_with(parser): | |
| def decor(func): | |
| def __get__(self, instance, owner=None): | |
| return self.__class__(instance, owner) | |
| def __call__(self, *args, **kwargs): | |
| params = parser.parse_args() | |
| if self.instance: | |
| return func(self.instance, params, *args, **kwargs) | |
| return func(params, *args, **kwargs) | |
| def __init__(self, instance=None, owner=None): |
| #!sh | |
| function newline() { printf "$@\n"; } | |
| function color() { | |
| output="\e[$1m" | |
| shift | |
| [ -n "$1" ] && output="$output$@\e[00m" | |
| printf "$output" | |
| } | |
| function reset() { color "00"; } |
Suppose I have blocking process blocking_process:
import os
os.system('rm -fr /tmp/pipe; mkfifo /tmp/pipe')
print len(open('/tmp/pipe').read())
On Linux, I might check what is it blocking on by doing:
$ strace -p $(pgrep -f blocking_process)
| $ pip freeze | |
| ipython==0.13 | |
| readline==6.2.2 | |
| wsgiref==0.1.2 | |
| $ cat test.py | |
| from IPython import embed ; embed() | |
| import thread ; thread.start_new_thread(lambda: 5/0, ()) | |
| $ python test.py | |
| Python 2.7.1 (r271:86832, Jul 31 2011, 19:30:53) | |
| Type "copyright", "credits" or "license" for more information. |
| #! /usr/bin/env python | |
| # | |
| # Mixpanel, Inc. -- http://mixpanel.com/ | |
| # | |
| # Python API client library to consume mixpanel.com analytics data. | |
| import hashlib | |
| import urllib | |
| import time | |
| try: |
| $ cat > ok.coffee | |
| 1 | |
| 2 | |
| $ cat > bad.coffee | |
| 1 | |
| 2 | |
| $ coffee -cs < ok.coffee | |
| // Generated by CoffeeScript 1.3.3 | |
| (function() { | |
| 1; |
| dirtys () { | |
| if ! which redis-server > /dev/null | |
| then | |
| echo no redis, no dirtys | |
| return 1 | |
| fi | |
| redis-server - <<EOF | |
| timeout 0 | |
| logfile stdout | |
| databases 1 |
| boto==2.3.0 | |
| gevent==0.13.7 | |
| greenlet==0.3.4 | |
| wsgiref==0.1.2 |
| % heroku apps:create -s cedar restpaste | |
| Creating restpaste... done, stack is cedar | |
| http://restpaste.herokuapp.com/ | [email protected]:restpaste.git | |
| Git remote heroku added | |
| % heroku addons:remove shared-database:5mb | |
| ! WARNING: Potentially Destructive Action | |
| ! This command will affect the app: restpaste | |
| ! To proceed, type "restpaste" or re-run this command with --confirm restpaste |
| #!/usr/bin/env bash | |
| cprint () { | |
| printf "%b" "\e[1;37m${1}\e[0m\n" | |
| } | |
| usage() { | |
| cat << EOF | |
| usage: $0 [OPTIONS] <src> <dst> | |
| --confirm <dst> dont ask for confirmation before destroying and restoring into <dst> |