Re: How to kill/timeout threads | non-blocking IO with stdin

2018-11-28 Thread mashingan
@trtt I thought I gave you example, but anyway, it's here [https://github.com/mashingan/nim-etc/blob/master/cond_loop.nim](https://github.com/mashingan/nim-etc/blob/master/cond_loop.nim)

Re: How to kill/timeout threads | non-blocking IO with stdin

2018-11-28 Thread trtt
I don't have the code yet because I'm about to write it(actually, I've a very different code but the problem is that I need the timeout mechanism, otherwise the program can't cooperate properly). But I'll quote my problem again: "I need this to be able to communicate with another pr

Re: How to kill/timeout threads | non-blocking IO with stdin

2018-11-28 Thread dom96
I don't know details of your application, but... What you could do is store the `FlowVar` (the object that spawn returns) for the thread that is waiting for stdin, wait for the FlowVar to finish for timeout seconds. If it finishes before timeout then use the returned value and re-spawn

Re: How to kill/timeout threads | non-blocking IO with stdin

2018-11-28 Thread trtt
Ok, but I need a timeout too, non-blocking stdin is not enough.

Re: How to kill/timeout threads | non-blocking IO with stdin

2018-11-28 Thread mratsim
`stdin` will block a whole thread (this is not nim specific), so you need to spawn a reader thread to read from stdin, async will not work. Note that how to read from `stdin` in a non-blocking way seems to be a popular question on Google search as there are Gevents, Python, D, Rust, Vala and

Re: How to kill/timeout threads | non-blocking IO with stdin

2018-11-28 Thread trtt
How would you instruct it to quit if it's blocked by stdin?

Re: How to kill/timeout threads | non-blocking IO with stdin

2018-11-27 Thread mashingan
Directly, you can't. But you can instruct it through channel to break/return/quit your other thread. Just message it to quit and put the logic when receiving the message that your thread is to quit.

Re: How to kill/timeout threads | non-blocking IO with stdin

2018-11-27 Thread trtt
Sorry, I don't understand - can I suspend or kill a parallel concurrency unit with that?

Re: How to kill/timeout threads | non-blocking IO with stdin

2018-11-26 Thread mashingan
try with combination of channel, lock and condition ? like this [example](https://forum.nim-lang.org/\(https:/github.com/mashingan/nim-etc/blob/master/cond_loop.nim)

Re: How to kill/timeout threads | non-blocking IO with stdin

2018-11-26 Thread trtt
I want to kill the thread after a certain amount of time. I need this to be able to communicate with another program in a single thread without blocking forever and without race issues.

Re: How to kill/timeout threads | non-blocking IO with stdin

2018-11-26 Thread dom96
What do you mean by "intercept"? And why do you need this?

Re: How to kill/timeout threads | non-blocking IO with stdin

2018-11-26 Thread trtt
Is it possible to intercept the thread? I couldn't find anything in the threadpool module...

Re: How to kill/timeout threads | non-blocking IO with stdin

2018-11-26 Thread dom96
Here is an example of how to mix stdin reading (with spawn) with async IO: [https://github.com/dom96/nim-in-action-code/blob/master/Chapter3/ChatApp/src/client.nim#L38-L50](https://github.com/dom96/nim-in-action-code/blob/master/Chapter3/ChatApp/src/client.nim#L38-L50)

How to kill/timeout threads | non-blocking IO with stdin

2018-11-26 Thread trtt
Hi, I want to timeout the reading from stdin and I couldn't find anything in the threads and os modules. It'd be also good if I could use stdin/read in a non-blocking way.

Re: Streaming HTTP request with timeout?

2018-10-02 Thread perturbation2
I probably am getting corrupted data at the end of stream, and just not noticing because ffmpeg does a good enough job at handling bad inputs. :( I'll take a closer look (and not close `bodyStream` unnecessarily). That's good information to know about issue 8994. I'll take a look at issue 7126

Re: Streaming HTTP request with timeout?

2018-10-01 Thread dom96
I can't really think of a better way to do this, the way your doing it looks good. I'm not sure why you're closing the `bodyStream` though, I'm surprised that doesn't cause issues. The HTTP client is only supposed to close it. Btw, beware of 0.19.0, you might run into a regression if you use

Streaming HTTP request with timeout?

2018-09-30 Thread perturbation2
rr: p.TError|p.TErrorCode) = if cast[p.TErrorCode](err) != p.NoError: raise newException(Exception, $p.GetErrorText(err)) proc requestAACWithTimeout(client: AsyncHttpClient, url: string, timeout: int = TIMEOUT_SECONDS) {.async.} = let resp = await client.get(url)

Re: How to change send timeout asyncftpclient

2018-04-19 Thread dom96
Okay, cool. Feel free to make a PR for this (it should be configurable and stored in AsyncFtpClient).

Re: How to change send timeout asyncftpclient

2018-04-19 Thread Seweryn
Yes, you can I modified **asyncftpclient.nim**. See _sendTimeout_ variable that count the seconds. The time out is hardcoded to 10s. proc doUpload(ftp: AsyncFtpClient, file: File, onProgressChanged: ProgressChangedProc) {.async.} = assert

Re: Timeout

2017-12-09 Thread qqtop
Thanks, that clears it up. I only was focused on the middle error message as it seemed to pertain to the issue at hand . As always reading docs is a real challenge...

Re: Timeout

2017-12-09 Thread Stefan_Salewski
Compiles fine with Nim Compiler Version 0.17.3 (2017-11-17) [Linux: amd64] Copyright (c) 2006-2017 by Andreas Rumpf git hash: 416aa921fa0cfefda5f3ee30329c8378f2e2008a active boot switches: -d:release

Timeout

2017-12-08 Thread qqtop
Issues with httpclient timeout import httpclient let callav = "https://github.com/nim-lang/Nim/blob/devel/tests/arithm/tand.nim; var zcli = newHttpClient() echo zcli.getContent(callav,timeout = 1) # < fails #echo zcli.getConten