ioerror

What is the proper way to handle (in python) IOError: [Errno 4] Interrupted system call, raised by multiprocessing.Queue.get

血红的双手。 提交于 2019-12-04 18:16:29
问题 When I use multiprocessing.Queue.get I sometimes get an exception due to EINTR. I know definitely that sometimes this happens for no good reason (I open another pane in a tmux buffr), and in such a case I would want to continue working and retry the operation. I can imagine that in some other cases The error would be due to a good reason and I should stop running or fix some error. How can I distinguish the two? Thanks in advance 回答1: The EINTR error can be returned from many system calls

How to avoid a Broken Pipe error when printing a large amount of formatted data?

雨燕双飞 提交于 2019-12-03 13:33:38
问题 I am trying to print a list of tuples formatted in my stdout . For this, I use the str.format method. Everything works fine, but when I pipe the output to see the first lines using the head command a IOError occurs. Here is my code: # creating the data data = []$ for i in range(0, 1000): pid = 'pid%d' % i uid = 'uid%d' % i pname = 'pname%d' % i data.append( (pid, uid, pname) ) # find max leghed string for each field pids, uids, pnames = zip(*data) max_pid = len("%s" % max( pids) ) max_uid =

python - specifically handle file exists exception

半腔热情 提交于 2019-12-03 11:01:29
I have come across examples in this forum where a specific error around files and directories is handled by testing the errno value in OSError (or IOError these days ?). For example, some discussion here - Python's "open()" throws different errors for "file not found" - how to handle both exceptions? . But, I think, that is not the right way. After all, a FileExistsError exists specifically to avoid having to worry about errno . The following attempt didn't work as I get an error for the token FileExistsError . try: os.mkdir(folderPath) except FileExistsError: print 'Directory not created.'

Why is mod_wsgi not able to write data? IOError: failed to write data

守給你的承諾、 提交于 2019-12-03 04:32:51
问题 What could be causing this error: $ sudo tail -n 100 /var/log/apache2/error.log' [Wed Dec 29 15:20:03 2010] [error] [client 220.181.108.181] mod_wsgi (pid=20343): Exception occurred processing WSGI script '/home/username/public_html/idm.wsgi'. [Wed Dec 29 15:20:03 2010] [error] [client 220.181.108.181] IOError: failed to write data Here is the WSGI script: $ cat public_html/idm.wsgi import os import sys sys.path.append('/home/username/public_html/IDM_app/') os.environ['DJANGO_SETTINGS_MODULE'

How to get the errno of an IOError?

杀马特。学长 韩版系。学妹 提交于 2019-12-02 19:06:49
C has perror and errno, which print and store the last error encountered. This is convenient when doing file io as I do not have to fstat() every file that fails as an argument to fopen() to present the user with a reason why the call failed. I was wondering what is the proper way to grab errno when gracefully handling the IOError exception in python? In [1]: fp = open("/notthere") --------------------------------------------------------------------------- IOError Traceback (most recent call last) /home/mugen/ in () IOError: [Errno 2] No such file or directory: '/notthere' In [2]: fp = open(

Why is mod_wsgi not able to write data? IOError: failed to write data

北城以北 提交于 2019-12-02 17:53:53
What could be causing this error: $ sudo tail -n 100 /var/log/apache2/error.log' [Wed Dec 29 15:20:03 2010] [error] [client 220.181.108.181] mod_wsgi (pid=20343): Exception occurred processing WSGI script '/home/username/public_html/idm.wsgi'. [Wed Dec 29 15:20:03 2010] [error] [client 220.181.108.181] IOError: failed to write data Here is the WSGI script: $ cat public_html/idm.wsgi import os import sys sys.path.append('/home/username/public_html/IDM_app/') os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' import django.core.handlers.wsgi application = django.core.handlers.wsgi.WSGIHandler()

Even with 'r' prepended to filename, openpyxl not able to save on Windows

别等时光非礼了梦想. 提交于 2019-12-02 13:28:34
问题 On OS X, openpyxl.save() is working fine for a file called 'all_done.xslx'. Yet when it is attempted on Windows, it results in: c:\Users\Tony\Desktop\ROI>python roi_cut6.py > log.txt Traceback (most recent call last): File "roi_cut6.py", line 373, in <module> main() File "roi_cut6.py", line 369, in main processSource(wb, 'Gemini', totalGeminiSpends, geminiRevenues) File "roi_cut6.py", line 269, in processSource wb.save(r'all_done.xlsx') File "C:\Python27\lib\site-packages\openpyxl\workbook

Python on Windows: IOError: [Errno 2] No such file or directory

我只是一个虾纸丫 提交于 2019-12-02 05:57:33
问题 First of all, I'm very new to Python and programming in general. Currently I'm trying to create a script that will remove all files with random names, extensions and content in the folder according to the lines from the blacklist (search must be done in the files' content). Here is a code: import os black_list = [line for line in open("C:/path/to/blacklist.txt")] for filename in os.listdir("C:/path/to/files/"): content = open(filename).read() if any(line in content for line in black_list): os

Even with 'r' prepended to filename, openpyxl not able to save on Windows

自古美人都是妖i 提交于 2019-12-02 04:17:44
On OS X, openpyxl.save() is working fine for a file called 'all_done.xslx'. Yet when it is attempted on Windows, it results in: c:\Users\Tony\Desktop\ROI>python roi_cut6.py > log.txt Traceback (most recent call last): File "roi_cut6.py", line 373, in <module> main() File "roi_cut6.py", line 369, in main processSource(wb, 'Gemini', totalGeminiSpends, geminiRevenues) File "roi_cut6.py", line 269, in processSource wb.save(r'all_done.xlsx') File "C:\Python27\lib\site-packages\openpyxl\workbook\workbook.py", line 298, in save save_workbook(self, filename) File "C:\Python27\lib\site-packages

IOError: [Errno Input overflowed] -9981

◇◆丶佛笑我妖孽 提交于 2019-12-02 03:20:24
问题 This question was migrated from Raspberry Pi Stack Exchange because it can be answered on Stack Overflow. Migrated 4 years ago . I am trying to execute a PyAudio python capturing program on Rasbian in my RaspberryPi model B board, but getting error: Traceback (most recent call last): File "/home/pi/pythonsound/record.py", line 35, in <module> data = stream.read(CHUNK) File "/usr/local/lib/python2.7/dist-packages/pyaudio.py", line 605, in read return pa.read_stream(self._stream, num_frames)