buffering

Having trouble with time.sleep

耗尽温柔 提交于 2019-12-11 01:51:33
问题 When I run, for example: print("[",end=" ") time.sleep(1) print("=",end=" ") time.sleep(1) print("=",end=" ") time.sleep(1) print("=",end=" ") time.sleep(1) print("=",end=" ") time.sleep(1) print("=",end=" ") time.sleep(1) print("=",end=" ") time.sleep(1) print("=",end=" ") time.sleep(1) print("=",end=" ") time.sleep(1) print("=",end=" ") time.sleep(1) print("=",end=" ") time.sleep(1) print("]",end=" ") Nothing happens for 10 seconds, then the whole [ = = = = = = = = = = ] appears. How can I

FileChannel#force and buffering

ⅰ亾dé卋堺 提交于 2019-12-10 09:28:22
问题 I would like to make it clear and draw some parallels between FileOutputStream and FileChannel right now. So first of all, it seems like the most efficient way to write file with standart Java io is to use FileOutputStream which is wrapped with BufferedOutputStream . Because it automatically flushes, when the internal buffer is overflowed. It is convenient to be able to do single writes (single bytes, floats, etc.) as well as array ones and to be not worried about speed. The only thing you

is there COMMIT analog in python for writing into a file?

笑着哭i 提交于 2019-12-08 19:10:54
问题 I have a file open for writing, and a process running for days -- something is written into the file in relatively random moments. My understanding is -- until I do file.close() -- there is a chance nothing is really saved to disk. Is that true? What if the system crashes when the main process is not finished yet? Is there a way to do kind of commit once every... say -- 10 minutes (and I call this commit myself -- no need to run timer)? Is file.close() and open(file,'a') the only way, or

How to correctly implement triple buffering?

早过忘川 提交于 2019-12-08 02:21:47
问题 I am trying to simulate videocard (producer thread) and a monitor(consumer thread), to figure out what is going on in educational purposes. So here is the technical task description: Producer thread produces frames pixel data at 1000 fps. Consumer thread runs at 60 fps and every frame it must have access to last produced frame for at least 1/60th of second. Each frame is represented by some int* , for simplicity. So my solution is that i have array of 2 pointers: one for producer, one for

Problem redirecting stdout in Ruby script

感情迁移 提交于 2019-12-07 18:32:32
问题 I have the following test Ruby script: require 'tempfile' tempfile = Tempfile.new 'test' $stderr.reopen tempfile $stdout.reopen tempfile puts 'test stdout' warn 'test stderr' `mail -s 'test' my@email.com < #{tempfile.path}` tempfile.close tempfile.unlink $stderr.reopen STDERR $stdout.reopen STDOUT The email that I get has the contents: test stderr Why is stderr redirecting properly but not stdout? Edit: In response to a comment I added a $stdout.flush after the puts line and it printed

MFC: How to avoid flickering in child-control updates?

这一生的挚爱 提交于 2019-12-07 14:51:42
问题 I'm been googling for days, and all I'm getting are the same answers, but is not what I want (I will describe what I do not want later). What I want is: Say I have a parent dialog that has a few CStatic child controls. The parent dialog uses black as its background when in focus, and gray when not in focus. The child static controls simply display text, but its background needs to follow the parent's background color Problem: I can get the child-controls to always track the parent's color,

MSMQ as buffer for SQL Server Inserts

China☆狼群 提交于 2019-12-07 13:41:43
问题 I'm learning about MSMQ and am successfully using it to queue email and text messages from a consumer-facing ASP.NET MVC website, to be handled by a separate client application. In the event of a missing SQL Server database, perhaps while swapping drives or a broken database deploy, would it make sense to queue non time-critical inserts in a local MSMQ queue to improve up-time? Theoretically, I can then pause/resume queue processing (persistence) while making database changes. Has anyone

unbuffered urllib2.urlopen

匆匆过客 提交于 2019-12-07 11:17:29
I have client for web interface to long running process. I'd like to have output from that process to be displayed as it comes. Works great with urllib.urlopen() , but it doesn't have timeout parameter. On the other hand with urllib2.urlopen() the output is buffered. Is there a easy way to disable that buffer? A quick hack that has occurred to me is to use urllib.urlopen() with threading.Timer() to emulate timeout. But that's only quick and dirty hack. urllib2 is buffered when you just call read() you could define a size to read and therefore disable buffering. for example: import urllib2

Reading multiple Python pickled data at once, buffering and newlines?

ぐ巨炮叔叔 提交于 2019-12-06 20:55:50
问题 to give you context: I have a large file f , several Gigs in size. It contains consecutive pickles of different object that were generated by running for obj in objs: cPickle.dump(obj, f) I want to take advantage of buffering when reading this file. What I want, is to read several picked objects into a buffer at a time. What is the best way of doing this? I want an analogue of readlines(buffsize) for pickled data. In fact if the picked data is indeed newline delimited one could use readlines,

How can we play/buffer only few minutes of a video in Android?

谁说胖子不能爱 提交于 2019-12-06 09:47:19
I need to play first 2 mins of a video. Using onBufferingUpdate() i get the percentage that is buffered. But by the time onPrepared is called i get buffered % as 40. Which is more than 2 mins of a video. (Considering i have a video of 30 mins) Is there any way i can play/buffer video for only 2 mins ? Thanks. The buffer size is pre-set into the firmware. All you can do is keep tabs on how much the buffer is filled, and even that is just on a percentage basis. The size is set in frameworks/base/media/libstagefright/include/NuCachedSource2.h check out this bug report on code.google.com. Edit: