blocking

Polling the keyboard in python

How can I poll the keyboard from a console python app? Specifically, I would like to do something akin to this in the midst of a lot of other I/O activities (socket selects, serial port access, etc.): while 1: # doing amazing pythonic embedded stuff # ... # periodically do a non-blocking check to see if # we...

How can I read from an IO::Socket::INET filehandle only if there is a complete line?

When reading from a IO::Socket::INET filehandle it can not be assumed that there will always be data available on the stream. What techniques are available to either peek at the stream to check if data is available or when doing the read take no data without a valid line termination and immediately pass through the read? ...

How to prevent overwriting an object someone else has modified

I would like to find a generic way of preventing to save an object if it is saved after I checked it out. We can assume the object has a timestamp field that contains last modification time. If I had checked out (visited a view using a ModelForm for instance) at t1 and the object is saved again at t2, given t2 > t1 I shouldn't be able t...

c# one Form blocking another in a winform Project

I have an application which uses 2 forms, a Main Form and a Splash Form being used in the following configuration: public class MainForm : Form { public MainForm() { SplashScreen splash = new SplashScreen(); // configure Splash Screen } } public class SplashScreen { public SplashScreen() { Ini...

Can SQL Server 2000 be made to populate a fulltext catalogue without blocking the tables it is reading?

I have a database server on SQL Server 2000 (yes I know...) with fulltext catalogues on some of its tables. I'm currently doing a full population overnight in quiet time, and I'd like to be able to update the catalogues during the day so that new data can be considered in searches. The problem I've noticed is that when an incremental po...

How do I perform a non-blocking fopen on a named pipe (mkfifo)?

If I have a program which creates and attempts to open a named pipe using mkfifo, how can I open a pipe for reading or writing without blocking? Specifically, I'm writing a C program which can be run with or without a gui (written in Java). In the C program, I successfully create the named pipes using mkfifo, however when I do FILE* i...

java inputstream read blocking

According to the java api, the InputStream.read() is described as: If no byte is available because the end of the stream has been reached, the value -1 is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown. I have a while(true) loop doing a read and I a...

How to avoid blocking (C++, Win32)

I'm making a dll that has to respond to an application's requests. One of the application's requirements is that a call should not take long to complete. Say, I have a function foo(), which is called by the host application: int foo(arg){ // some code i need to execute, say, LengthyRoutine(); return 0; } Lets say, foo has to perform ...

How would you implement a basic event-loop?

If you have worked with gui toolkits, you know that there is a event-loop/main-loop that should be executed after everything is done, and that will keep the application alive and responsive to different events. For example, for Qt, you would do this in main(): int main() { QApplication app(argc, argv); // init code return a...

Javascript blocking content download on your website during page

Is this the best way to include javascript on your website? http://www.webdigi.co.uk/blog/2009/avoid-javascript-blocking-content-download-on-your-website-during-page-load/ ...

Semaphore queues

I'm extending the functionality of a semaphore. I ran into a roadblock when I realized I don't know the implementation of an actual semaphore and to make sure my code ran correctly, I needed to know this. I know a semaphore works by blocking threads that are waiting on it when they call sem_wait() and another thread currently has it lo...

My IP seems to be blocked by web hosting server...

Hi All I have a strange problem, i just installed my php web site on a shared hosting, all services were working fine. But after configuring my app i just could visit my web site only once, other attempts gives "The server is taking too long to respond.". But from other IP i can access, but only once, it seems all ip addressess beeing b...

Anyway to detect if a threaded method has completed.

Hi, I've got a queue, which is basically the producer/consumer queue in the albahari.com threading book, which takes an queue item off the queue, which is an action execution block off the queue and then calls a method to execute the actionlist within the queue item. I can kill the queue easily enough by enqueing a null actionblock an...

second $(document).ready event jQuery

I'm using some external jQuery with $(document).ready() to insert adverts after the document ready event has fired, something like: $(document).ready($('#leaderboard').html("<strong>ad code</strong>"); This is to prevent the UI being blocked by the slow loading of the adverts. So far it's been working well. Now I need to insert some ...

SerialPort.Write() - How to stop writing?

Hello, I am developing in C# using the SerialPort class. SerialPort.Write() is a blocking method. How can I exit this method when I want to stop writing? I use a thread to write. I abort this thread when I want to stop writing but the COM port continues to write. Any ideas? Thanks a lot. Sorry for my basic English. ...

How to avoid Socket.EndReceive()blocking when no data is available

I am using the BeginReceive() and EndReceive() method for async IO using Sockets in .NET. The client sends continuous packets of data and calling EndReceive() returns the number of bytes read. The problem is that the client is sending packets of data but data length is ZERO. It found this by analyzing the traffic in WireShark. When the ...

How to interrupt a BlockingQueue which is blocking on take()?

I have a class that takes objects from a BlockingQueue and processes them by calling take() in a continuous loop. At some point I know that no more objects will be added to the queue. How do I interrupt the take() method so that it stops blocking? Here's the class that processes the objects: public class MyObjHandler implements Runna...

mod_security blocks IP when script fails with error ?

Hi I have problem with blocking my IP, i installed php application on shared hosting and tryed to run it, but it gave some errors, then i tried to refresh the page, but after 3 rd attempt my ip got blocked to all ports. No available service(ftp,ssh). Apache mod_securty blocks it ? Thanks. ...

Simulating a locked/hung application

I have an application that interacts with another application using SendMessage (among other things). Everything works fine until the other application hangs (either because it has actually frozen or it is doing a long, blocking call). I would like to simulate an application hanging using a C# WinForms application. Is there any way to st...

Windows: How to display a non-blocking Alert/Confirmation window?

I want to realize a simple confirmation/alert box which can be called using a Windows XP/Vista batch script by CLI. The standard alert box seems to be blocking which means that the whole batch script will stop at the time of the alert window call which is NOT what I want. If it needs to be coded, please supply an example or documentati...