Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 timeout for io.read()
#1
has anyone put together a way to read an open file with a timeout (returns something different or raises an exception if nothing to read by the end of the specified timeout period)? a search on google just comes up with lots of socket references or suggestions for select/poll (which does not work on all files).
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Quote
#2
I found once an interesting timeout decorator based on multiprocessing.pool.ThreadPool.apply_sync(). Tell us if it suits your needs.
Quote
#3
i went ahead and read that, hoping it might fill in the gaps in my lack of understanding decorators. but it didn't. it focuses on timer signals. my original thought for an I/O timeout was to use os.select() or, as you suggested in another thread, select.select(). the idea was just to have a read() (i hadn't thought about writing, yet) that has a timeout= option. but that commits the code to waiting for only one input source at a time. that's why i was looking around for a general multi-I/O way.

i just don't know if a decorator can achieve any of what i want to do. i still don't understand decorators. my first thought is that must be some kind of wrapper around the function call. be i get responses like "not quite" which suggests it is more complicated (something to avoid when not essential). but i have found a good explanation. i need one that is not limited to just explaining what can be done, but also explains how it is done in deeper detail suitable for people who already do deep stuff in other languages (as opposed to most people who are learning python as their first language). i could have created a language like this, but there would also be many important differences. if someone wanted me to add decorators to it, how would they describe what they should do?
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Quote
#4
Quote:the idea was just to have a read() (i hadn't thought about writing, yet) that has a timeout= option. but that commits the code to waiting for only one input source at a time
The method selectors.BaseSelector.select() has a timeout parameter. It could be the solution.
Quote
#5
i do need to go through select and selectors thoroughly a few times. if that isn't the solution, it's probably in there somewhere.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Quote

Top Page

Forum Jump:


Users browsing this thread: 1 Guest(s)