nonblocking

how to do asynchronous http requests with epoll and python 3.1

there is an interesting page http://scotdoyle.com/python-epoll-howto.html about how to do asnchronous / non-blocking / AIO http serving in python 3. there is the tornado web server which does include a non-blocking http client. i have managed to port parts of the server to python 3.1, but the implementation of the client requires pyCur...

Java - Handling Non-Blocking Calls

In my application I am using a third-party API. It is a non-blocking method which returns immediately. I have a collection of elements over which I have to invoke this method. Now, my problem is that I have to find a way till all the method execution gets completed and do my next operation. How can I handle this? I cannot modify the thi...

Is there an use case for non-blocking receive when I have threads?

I know non-blocking receive is not used as much in message passing, but still some intuition tells me, it is needed. Take for example GUI event driven applications, you need some way to wait for a message in a non-blocking way, so your program can execute some computations. One of the ways to solve this is to have a special thread with m...

Poll SelectMode.Read throws WouldBlock all the time on client

I have another tricky situation with my socket experience. I'm writing a non-blocking server/client for some key-value data storage. Here's the situation: connect to server post data to it (wait for no confirmation that data's being submited) right after then (staying on the same connected socket) I'm trying to read that data Here's...

Jetty 7 NIO issue?

I saw this test showing Jetty 7's performance drops drastically when switched from blocking IO to NIO (95% drop): http://wiki.apache.org/HttpComponents/HttpCoreBenchmark Is this a known issue? Have you experienced it first hand? Should I be avoiding NIO on Jetty? ...

Testing a Non-blocking Queue

I've ported the non-blocking queue psuedocode here to C#. The code below is meant as a near verbatim copy of the paper. What approach would you take to test the implementation? Note: I'm running in VS2010 so I don't have CHESS support yet. Edit: I've removed the code in question so some unsuspecting developer doesn't use it -- it req...

Ruby Win32Api get single character non-blocking

I'm trying to write a simple game working with two threads, one thread to get input from the user, and another thread to animate some scenes. I'm able to get characters without pressing ENTER just fine, but it blocks in the animating thread until the user presses a key. Does anyone know of a way to get a character from the keyboard non...

Nonblocking Tcp server

It's not a question really, i'm just looking for some guidelines :) I'm currently writing some abstract tcp server which should use as low number of threads as it can. Currently it works this way. I have a thread doing listening and some worker threads. Listener thread is just sits and wait for clients to connect I expect to have a sin...

Why is a non-blocking TCP connect() occasionally so slow on Linux?

I was trying to measure the speed of a TCP server I'm writing, and I've noticed that there might be a fundamental problem of measuring the speed of the connect() calls: if I connect in a non-blocking way, connect() operations become very slow after a few seconds. Here is the example code in Python: #! /usr/bin/python2.4 import errno imp...

check whether fgets would block

Hi, I was just wondering whether in C is it possible to peek in the input buffer or perform similar trickery to know whether a call to fgets would block at a later time. Java allows to do something like that by calling BufferedReader.ready(), this way I can implement console input something like this: while (on && in.ready()) { line ...

Asynchronous event loop design and issues.

Hello, I'm designing event loop for asynchronous socket IO using epoll/devpoll/kqueue/poll/select (including windows-select). I have two options of performing, IO operation: Non-blocking mode, poll on EAGAIN Set socket to non-blocking mode. Read/Write to socket. If operation succeeds, post completion notification to event loop. If ...

Is there a non-blocking version of MessageBox.Show (or something like it)?

Long-delayed update I'm accepting MUG4N's answer to this question, and I also want to respond to some of the criticisms that were raised against it. ChrisF said: ...you can't make UI calls directly from background threads. This is a blanket statement, and is not 100% true. Let me just point out a few facts: You can actually mak...

In Java What is the guaranteed way to get a FileLock from FileChannel while accessing a RandomAccessFile ?

I am trying to use FileLock lock(long position, long size,boolean shared) in FileChannel object As per the javadoc it can throw OverlappingFileLockException. When I create a test program with 2 threads lock method seems to be waiting to acquire the lock (both exclusive and non exclusive) But when the number threads increases in the a...

Force blocking read after EAGAIN?

I have a file descriptor that is open for reading which may be non-blocking. What I need to do is simply read all data until reaching EOF and write that data to a writable file descriptor. As the process that performs this copying is not "aware" of anything that is going on around it, I don't think that I can do something useful while wa...

Is O_NONBLOCK being set a property of the file descriptor or underlying file?

From what I have been reading on The Open Group website on fcntl, open, read, and write, I get the impression that whether O_NONBLOCK is set on a file descriptor, and hence whether non-blocking I/O is used with the descriptor, should be a property of that file descriptor rather than the underlying file. Being a property of the file descr...

Fast way to pass a simple java object from one thread to another

I have a callback which receives an object. I make a copy of this object, and I must pass it on to another thread for further processing. It's very important for the callback to return as fast as possible. Ideally, the callback will write the copy to some sort of lock-free container. I only have the callback called from a single thread ...

What is the point/purpose of Ruby EventMachine, Python Twisted, or JavaScript Node.js?

I don't understand what problem these frameworks solve. Are they replacements for a HTTP server like Apache HTTPD, Tomcat, Mongrel, etc? Or are they more? Why might I use them... some real world examples? I've seen endless examples of chat rooms and broadcast services, but don't see how this is any different than, for instance, setti...

recv with MSG_NONBLOCK and MSG_WAITALL

Hello I want to use recv syscall with nonblocking flags MSG_NONBLOCK. But with this flag syscall can return before full request is satisfied. So, can I add MSG_WAITALL flag? Will it be nonblocking? or how should I rewrite blocking recv into the loop with nonblocking recv ...

PyQt blocking version of show()

I've got a fairly cpu-intensive application, but all of the cpu-intensive stuff is started by clicking a QPushButton. When the button is clicked, a hidden QLabel is show()n. Apparently, show() is non-blocking. Unfortunately, this means that the cpu-intensive stuff is practically half-done before the label show()s up. How can I make s...

Java / Groovy Socket - Detecting the socket being closed in a non-blocking way

I'm trying to create a small HTTP proxy that can re-write the request/headers as needed to suit my requirements. If one already exists, please, point me to it. Otherwise... I've written something that ALMOST works. It can do the proxy function, but not the re-write (yet). Problem is, I can't detect when the remote socket has been cl...