I read many files from my system. I want to read them faster, maybe like this:
results=[]
for file in open("filenames.txt").readlines():
results.append(open(file,"r").read())
I don't want to use threading. Any advice is appreciated.
the reason why i don't want to use threads is because it will make my code unreadable,i want to fi...
Hello,
I'm trying to manage a ssh connection to a network device via the PTY module, with a code similar to this :
cmd_line = "ssh [email protected]"
begin
PTY.spawn(cmd_line) do |r_f,w_f,pid|
...
rescue PTY::ChildExited => cended
...
end
The whole i/o works pretty well, however I don't know how to get the exit status...
An OutputStream obj can be connected into a PrintWriter obj directly, e.g.,
//either is OK
new PrintWriter(socket.getOutputStream());
new PrintWriter(new OutputStreamWriter(socket.getOutputStream()));
But in the case of an InputStream obj, it must be connected to a BufferedReader obj through an InputStreamReader obj, that is,
new Buff...
Hi everyone,
I've seen this code (and similar) all over the web, but I just cannot get it to work. Whenever I debug it line by line, it breaks out of debugging and loads the application. No error messages are presented, and any code after the "faulty" line remains unprocessed.
Here is the offending code:
foreach (string folder in allF...
I followed the instructions in the README, they are very simple
cd build
cmake ..
make install
The problem occurs after the make install command. Io will not compile, specifically because of the module CFFI. ld complains that my libffi.dylib is not 64-bit, and thus it won't link the .o files, and because of that, it then complains tha...
VB.NET 2010, .NET 4
Hello,
I currently have a class that represents a serial device. The communication paradigm is: Send a command/request, the device then sends an acknowledged or not-acknowledged byte. If acknowledged, the device sends its response.
The way this is being done right now is: A timer periodically sends a command/re...
For an exercise I'm doing, I'm trying to read the contents of a given file twice using the read() method. Strangely, when I call it the second time, it doesn't seem to return the file content as a string??
Here's the code
f = f.open()
# get the year
match = re.search(r'Popularity in (\d+)', f.read())
if match:
print match.group(1)
...
I ask here since googling leads you on a merry trip around archives with no hint as to what the current state is. If you go by Google, it seems that async IO was all the rage in 2001 to 2003, and by 2006 some stuff like epoll and libaio was turning up; kevent appeared but seems to have disappeared, and as far as I can tell, there is sti...
i have a very simple c/c++ program that forks a child process to execute another program, and then sends some data to that child program, and waits for the response.
the child program reads from stdin and waits for EOF before it continues.
my problem is, the child program receives the initial input from the pipe writing, but it never s...
I am pulling data from a bzip2 stream within a C application. As chunks of data come out of the decompressor, they can be written to stdout:
fwrite(buffer, 1, length, stdout);
This works great. I get all the data when it is sent to stdout.
Instead of writing to stdout, I would like to process the output from this statement internally...
I've been scouring the Internet looking for a solution to my problem with Python. I'm trying to use a urllib2 connection to read a potentially endless stream of data from an HTTP server. It's part of some interactive communication, so it's important that I can get the data that's available, even if it's not a whole buffer full. There se...
There are a number of reasons to call CancelIo, but in my particular case I'm calling it in order to know that the system is no longer writing into a buffer. Once I know that, I can safely free the buffer.
But what if CancelIo fails? What I do now is explicitly leak the buffer and throw an exception. Are there better ways to deal with t...
I have a Python application that, to be brief, receives data from a remote server, processes it, responds to the server, and occasionally saves the processed data to disk. The problem I've encountered is that there is a lot of data to write, and the save process can take upwards of half a minute. This is apparently a blocking operation, ...
Hi all,
I am supposed to write a simple Cinema Booking System, which allows a customer to make reservations for movies.
The Cinema consists or different theatres, with different amount of seats, price and movie showtimes.
The user should be able to input his name and other credentials and then make reservations for 1 or more movies a...
when i read the entire XML file in JEditorPane all works fine except the BOM charatcer. I get a BOM charatcer (a dot) at start of file. If i remove the dot and save file it is saved as ANSI.In notepad++ it shows (ANSI as UTF-8) encoding for the same file. If i dont remove the dot XML parser fails to parse the document. Can u help me with...
Is there a way to write a program to output ON/OFF/ON/OFF sequence to one of USB, RS-232, or Parallel port? The On probably will be 5V or is "close circuit", and Off will be 0V or is "open circuit".
Can the frequency be very high? This can be achieve long time ago by using TTL chips and a "clock", and programming in Microcode, which i...
Hi, I run a FreeBSD NFS server and recently I've been having odd issues throughout the cluster (the Apache servers are hanging in "lockf" state when loading files from the NFS share, etc).
I'm fairly new to this, so my question is how can I tell if a server's IO is getting overloaded?
Here is my current iostat:
[root@host ~]# iostat...
I am a little confused as to the steps of reading a file into buffer gradually.
from the MSDN docs
public abstract int Read(
byte[] buffer,
int offset,
int count
)
source from C# Examples
FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read);
try
{
int length = (int)fileStream.Length; // ...
You know the feature for example, you opened C:\test.txt if you also have the same file in another editor, and you edit it there, when you return, the app will prompt that the file has changed, whether you want to update it. How do I check if the file has been updated?
UPDATE
Asked a sister question "Using FileSystemWatcher to watch fo...
Ok, so I learnt from How to check if a open file has been updated that I should use a FileSystemWatcher to watch for changes to files. Then now, the question is if I must keep track of many files, do I create 1 watcher for each file? Also, I must somehow dispose of the watcher once the file is closed. Is having a Dictionary<string, File...