nonblocking

Reliable non blocking reads from subprocess stdout

孤者浪人 提交于 2019-12-23 16:17:07
问题 Note: I have a process that writes one line to stdout ("print("hello")) and waits for raw_input. I run this process with p = subprocess.Popen, then call p.stdout.readline()....this blocks indefinitely. I am setting shell=False...Why can I not read that first output? p = subprocess.Popen(cmd, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin = subprocess.PIPE) print(p.stdout.readline()) I have seen this thread about non blocking io for subprocess. I am trying to create an

Time out idle connections in epoll based server

风流意气都作罢 提交于 2019-12-23 03:36:11
问题 I'm writing a tcp server in c that uses epoll() i/o multiplexing to manage concurrent connections. I want to timeout connections that have been idle for more than an allowed time. So far I keep a last_active time_t variable associated with each connection, which I update to the current time in the event handler. Before doing that, I check if more than the allowed time has ellapsed since last event and if so I terminate the connection. So far so good but it's not really what I want because the

Verilog blocking/nonblocking assignment in clk generator with self triggered

戏子无情 提交于 2019-12-23 01:20:08
问题 Why the following code is not self-triggered? module osc1 (clk); output clk; reg clk; initial #10 clk = 0; always @(clk) #10 clk = ~clk; always begin $monitor("%0d clk=%0d\n",$time,clk); #100 $finish; end endmodule output: # 0 clk=x # 10 clk=0 # 20 clk=1 when used non-blocking assignment it works normally i.e., always @(clk) #10 clk <= ~clk; output: # 0 clk=x # 10 clk=0 # 20 clk=1 # 30 clk=0 # 40 clk=1 # 50 clk=0 # 60 clk=1 # 70 clk=0 # 80 clk=1 # 90 clk=0 thanks in advance. 回答1: It has to do

Non-blocking TCP buffer issues

有些话、适合烂在心里 提交于 2019-12-23 01:14:26
问题 I think I'm in a problem. I have two TCP apps connected to each other which use winsock I/O completion ports to send/receive data (non-blocking sockets). Everything works just fine until there's a data transfer burst. The sender starts sending incorrect/malformed data. I allocate the buffers I'm sending on the stack, and if I understand correctly, that's a wrong to do, because these buffers should remain as I sent them until I get the "write complete" notification from IOCP. Take this for

Node.js: Object value as stdout of child_process.exec

喜你入骨 提交于 2019-12-22 16:45:15
问题 I'm new to Node and stumbling on some of the nonblocking elements of it. I'm trying to create a object and have one of the elements of it being a function that returns the stdout of a child_process.exec, like so: var exec = require('child_process').exec; var myObj = {}; myObj.list = function(){ var result; exec("ls -al", function (error, stdout, stderr) { result = stdout; }); return result; } console.log('Ta da : '+myObj.list); I figure that myObj.list is returning result before it is set as

Node.js: Object value as stdout of child_process.exec

人盡茶涼 提交于 2019-12-22 16:45:01
问题 I'm new to Node and stumbling on some of the nonblocking elements of it. I'm trying to create a object and have one of the elements of it being a function that returns the stdout of a child_process.exec, like so: var exec = require('child_process').exec; var myObj = {}; myObj.list = function(){ var result; exec("ls -al", function (error, stdout, stderr) { result = stdout; }); return result; } console.log('Ta da : '+myObj.list); I figure that myObj.list is returning result before it is set as

difference between blocking and non blocking statements with intra-assignment delay

坚强是说给别人听的谎言 提交于 2019-12-22 10:03:55
问题 What is the difference between the following 2 snippets of verilog code? 1) always@(in) out = #5 in; AND 2) always@(in) out <= #5 in; Considering no other lines are present in the always block, can there be any difference in output? question is in reference to slide 16 (see o5 and o6 outputs) http://www.sutherland-hdl.com/papers/1996-CUG-presentation_nonblocking_assigns.pdf 回答1: out = #5 in; blocks the next operation for 5 time units. It will prevent the monitoring of the next @(in) until the

Non blocking event scheduling in python

允我心安 提交于 2019-12-22 06:22:52
问题 Is it possible to schedule a function to execute at every xx millisecs in python,without blocking other events/without using delays/without using sleep ? What is the best way to repeatedly execute a function every x seconds in Python? explains how to do it with sched module, but the solution will block the entire code execution for the wait time(like sleep). The simple scheduling like the one given below is non blocking, but the scheduling works only once- rescheduling is not possible. from

Java / Scala Future driven by a callback

那年仲夏 提交于 2019-12-22 05:42:06
问题 Short Version: How can I create a Promise<Result> which is completed on a trigger of a callback? Long Version: I am working on an application which deals with third-party SOAP services. A request from user delegates to multiple SOAP services simultaneously, aggregates the results and sends back to the user. The system needs to be scalable and should allow multiple concurrent users. As each user requests ends up triggering about 10 web service calls and each call blocking for about 1 second,

Java / Scala Future driven by a callback

只谈情不闲聊 提交于 2019-12-22 05:42:00
问题 Short Version: How can I create a Promise<Result> which is completed on a trigger of a callback? Long Version: I am working on an application which deals with third-party SOAP services. A request from user delegates to multiple SOAP services simultaneously, aggregates the results and sends back to the user. The system needs to be scalable and should allow multiple concurrent users. As each user requests ends up triggering about 10 web service calls and each call blocking for about 1 second,