Questions tagged [nonblocking]

Non-blocking mode I/O either transfers at least one byte or returns immediately with an error or end of stream. Non-blocking algorithms refer to use of concurrency without the usual mutual exclusion primitives, guaranteeing that thread operations will not block indefinitely. This is usually handled with atomic value modification (increment/decrement) and/or reading (compare-and-exchange) operations.. It isn't clear which this tag is intended for.

1597 questions
21
votes
1 answer

What's the difference between async and nonblocking in unix socket?

I'm seeing such code in nginx: if(fcntl(ngx_processes[s].channel[0], F_SETFL, fcntl(s, F_GETFL) | O_NONBLOCK) == -1) { ... if (ioctl(ngx_processes[s].channel[0], FIOASYNC, &on) == -1) { ... Anyone can tell me what's the difference between fcntl(s,…
cpuer
  • 7,413
  • 14
  • 35
  • 39
21
votes
3 answers

Python - Timer with asyncio/coroutine

I am trying to set a timer that will interrupt the running process and call a coroutine when it fires. However, I'm not sure what the right way to accomplish this is. I've found AbstractEventLoop.call_later, along with threading.Timer but neither of…
Greg Miller
  • 328
  • 1
  • 2
  • 6
21
votes
3 answers

How to readline infinitely in Node.js

while(1){ rl.question("Command: ",function(answer){ console.log(answer); }) } Just tried this code, but instead get input one by one, it blink the "Command: " line. I know node.js is non-blocking but i don't know how to fix this…
user2477
  • 896
  • 2
  • 10
  • 23
21
votes
3 answers

Is it possible to do asynchronous / parallel database query in a Django application?

I have web pages that take 10 - 20 database queries in order to get all the required data. Normally after a query is sent out, the Django thread/process is blocked waiting for the results to come back, then it'd resume execution until it reaches the…
Continuation
  • 12,722
  • 20
  • 82
  • 106
21
votes
5 answers

How to use QThread correctly in pyqt with moveToThread()?

i read this article How To Really, Truly Use QThreads; The Full Explanation, it says instead of subclass qthread, and reimplement run(), one should use moveToThread to push a QObject onto QThread instance using moveToThread(QThread*) here is the…
Shuman
  • 3,914
  • 8
  • 42
  • 65
21
votes
2 answers

How to read named FIFO non-blockingly?

I create a FIFO, and periodically open it in read-only and non-blockingly mode from a.py: os.mkfifo(cs_cmd_fifo_file, 0777) io = os.open(fifo, os.O_RDONLY | os.O_NONBLOCK) buffer = os.read(io, BUFFER_SIZE) From b.py, open the fifo for writing: out…
chaonin
  • 227
  • 1
  • 2
  • 6
20
votes
5 answers

NodeJs how to create a non-blocking computation

I am trying to get my head around creating a non-blocking piece of heavy computation in nodejs. Take this example (stripped out of other stuff): http.createServer(function(req, res) { console.log(req.url); sleep(10000); res.end('Hello…
Tallmaris
  • 7,605
  • 3
  • 28
  • 58
20
votes
6 answers

Detect key press (non-blocking) w/o getc/gets in Ruby

I have a simple task that needs to wait for something to change on the filesystem (it's essentially a compiler for prototypes). So I've a simple infinite loop with a 5 second sleep after the check for changed files. loop do # if files changed #…
Robert K
  • 30,064
  • 12
  • 61
  • 79
20
votes
5 answers

End of nonblocking file

How is end of file detected for a file in nonblocking mode?
Matt Joiner
  • 112,946
  • 110
  • 377
  • 526
20
votes
2 answers

Tomcat NIO thread pools

I understand Java NIO (channels, selector, ..). I would like to understand Tomcat NIO better so that I can configure thread pools of Tomcat appropriately from Spring boot. Can someone please explain what is the purpose of each thread pool and how do…
Rag
  • 1,363
  • 4
  • 19
  • 36
20
votes
5 answers

Non-blocking sockets

What's the best way to implement a non-blocking socket in Java? Or is there such a thing? I have a program that communicates with a server through socket but I don't want the socket call to block/cause delay if there is a problem with the…
jasonline
  • 8,646
  • 19
  • 59
  • 80
20
votes
3 answers

Understanding NodeJS & Non-Blocking IO

So, I've recently been injected with the Node virus which is spreading in the Programming world very fast. I am fascinated by it's "Non-Blocking IO" approach and have indeed tried out a couple of programs myself. However, I fail to understand…
Vishwas Shashidhar
  • 807
  • 2
  • 9
  • 23
19
votes
3 answers

Explain Michael & Scott lock-free queue alorigthm

I am studying Michael & Scott's lock-free queue algorithm and trying to implemented it in C++. But I produced a race in my code and think there may be a race in the algorithm. I read the paper here: Simple, Fast, and Practical Non-Blocking and…
Eddie Deng
  • 1,399
  • 1
  • 18
  • 30
19
votes
4 answers

Is Tornado really non-blocking?

Tornado advertises itself as "a relatively simple, non-blocking web server framework" and was designed to solve the C10k problem. However, looking at their database wrapper, which wraps MySQLdb, I came across the following piece of code: def…
ipartola
  • 1,612
  • 3
  • 15
  • 25
18
votes
3 answers

socket select ()versus non-block recv

I've seen a few write-ups comparing select() with poll() or epoll(), and I've seen many guides discussing the actual usage of select() with multiple sockets. However, what I can't seem to find is a comparison to a non-blocking recv() call without…
Gren Meera
  • 181
  • 1
  • 1
  • 4