• Home
  • What's Tribler
  • Download
  • FAQ
  • Forum
Tribler

Wiki Navigation


Blocking Functions

The following functions can cause the current thread to block (i.e. can take seconds or minutes to complete):

Network-related

The following operations can block, because they need to look up a hostname, or retrieve a remote resource. To do non-blocking retrievals, use select.select or socket.setblocking(0).

socket.accept
socket.close
socket.connect
socket.getfqdn
socket.getaddrinfo
socket.gethostbyname
socket.gethostbyaddr
socket.getnameinfo
socket.getnameinfo_ex
socket.recv
socket.recv_into
socket.recvfrom
socket.recvfrom_into
socket.send
socket.sendall
socket.sendto
urllib.urlopen
urllib.urlretrieve

File-related

The following operations can block, because disk-access can be slow or even across a network. Even writing to stdin/stdout/stderr can block, or reads from another process. Arno says: these should be safe to use as long as your not on a network file system. If we can't use these, things get complicated ;o)

file.close
file.flush
file.open
file.read
file.readlines
file.truncate
file.write
file.writelines
file.xreadlines
os.access
os.chdir
os.chmod
os.chown
os.close
os.fchdir
os.fdopen
os.fstat
os.fstatvfs
os.fsync
os.ftruncate
os.listdir
os.lstat
os.makedirs
os.mkdir
os.mkfifo
os.mknod
os.open
os.read
os.readlink
os.remove
os.removedirs
os.rename
os.renames
os.rmdir
os.stat
os.stat_float_times
os.statvfs
os.symlink
os.tempnam
os.tmpfile
os.tmpnam
os.walk
os.write

Process-related

The following commands can block because they wait for something to finish (for some, a timeout of zero can be used to avoid blocking):

os.system
os.wait
os.wait3
os.wait4
os.waitpid
threading.Thread.join

Time-related

The following commands can block because they (can) wait for time to pass:

select.select
time.sleep

Lock-related

The following commands can block because they need some (user-created) lock. Some of these can be explicitly set to non-blocking:

thread.allocate_lock.acquire
threading.BoundedSemaphore.acquire
threading.Condition.acquire
threading.Condition.wait
threading.Event.wait
threading.Lock.acquire
threading.RLock.acquire
threading.Semaphore.acquire

Latest news

29 April 2008

Tribler Team organized a successful course on Advanced P2P Technology
Read More

17 February 2008

19 Million Euro for P2P research
Read More

Please contact us if you have found a news item that's not listed here.


  • News
  • Developers
  • Business
  • Research
  • Jobs
  • About Us
  • Press
  • Contact
Login