I am looking for a file like io data structure in python that does not use files at all. So just a memory file. I tried cStringIO, which is quite what I was looking for with the limitation that it is not usable via select. That is sound, but is there a data structure that fulfills both requirements in some way? I think select is a nice and comfortable way to check fds for updates.
Asked
Active
Viewed 172 times
0
-
1The reason select doesn't work on StringIO is that select doesn't work on regular files at all. You can't use it to check if a file or file like object has been updated. – Jayanth Koushik Mar 06 '14 at 12:05
-
I can use select on file descriptors. Hence f = open(filename) and select.select([f],[],[]) should work, right? So I would recognise, whether something is ready to read. – mkind Mar 06 '14 at 12:10
-
@mkind `select()` reports files as always ready for I/O, which leads to a busy waiting loop. – Maxim Egorushkin Mar 06 '14 at 13:28
2 Answers
0
Although creating files on the file system, SpooledTemporaryFiles solved my issue.

mkind
- 2,015
- 2
- 20
- 25
0
Named pipes, sockets -- no content on the disk and they can be used with select
.

jfs
- 399,953
- 195
- 994
- 1,670