Pythonanywhere oserror write error

Forums : PythonAnywhere

This seems sort of right. Just today, I’ve gotten this many errors:

2019-10-08 11:17:44,606: OSError: write error
2019-10-08 11:17:44,608: OSError: write error
2019-10-08 11:17:44,622: OSError: write error
2019-10-08 12:21:50,935: OSError: write error
2019-10-08 14:46:05,534: OSError: write error
2019-10-08 14:46:05,535: OSError: write error
2019-10-08 16:05:28,771: OSError: write error
2019-10-08 16:16:03,225: OSError: write error
2019-10-08 16:16:18,039: OSError: write error
2019-10-08 16:47:11,276: OSError: write error
2019-10-08 16:47:11,301: OSError: write error
2019-10-08 17:41:29,032: OSError: write error
2019-10-08 17:45:55,173: OSError: write error
2019-10-08 19:06:37,768: OSError: write error
2019-10-08 19:06:37,783: OSError: write error
2019-10-08 21:02:06,188: OSError: write error
2019-10-09 00:26:46,175: OSError: write error
2019-10-09 00:27:46,375: OSError: write error
2019-10-09 01:19:09,919: OSError: write error
2019-10-09 01:57:23,046: OSError: write error
2019-10-09 01:57:23,106: OSError: write error
2019-10-09 03:16:00,727: OSError: write error
2019-10-09 04:22:51,426: OSError: write error
2019-10-09 11:02:28,651: OSError: write error
2019-10-09 12:01:18,268: OSError: write error
2019-10-09 12:24:24,783: OSError: write error
2019-10-09 12:24:24,816: OSError: write error
2019-10-09 15:30:31,227: OSError: write error
2019-10-09 15:30:31,226: OSError: write error
2019-10-09 15:33:22,601: OSError: write error
2019-10-09 16:42:37,676: OSError: write error
2019-10-09 16:44:19,278: OSError: write error
2019-10-09 16:44:19,619: OSError: write error
2019-10-09 16:47:06,667: OSError: write error
2019-10-09 16:48:54,776: OSError: write error
2019-10-09 16:48:54,789: OSError: write error
2019-10-09 16:49:27,862: OSError: write error
2019-10-09 16:56:18,781: OSError: write error
2019-10-09 16:57:16,560: OSError: write error

I’m worried that I can’t find what view specifically is causing the redirects — in addition, some are literally just 0.5 seconds response time — does this mean the website loaded in 0.5 seconds, or that they redirected away by going somewhere else after just 0.5 seconds. If it’s the former, there’s not much I can do about this right — they’re just leaving before my site’s loaded, right?

OSError: write error in error.log

I see a lot of «OSError: write error» message in my error log. Been there for weeks.

I’m not getting any errors in my app although I am writing data to disk to cache it.

Is this coming from the server level? It appears so.

Should I be concerned? Any insight as to the source of the error?

Thanks,
Chris

deleted-user-3683187
|
37
posts
|



Dec. 3, 2018, 4:46 a.m.

|
permalink

We had some trouble with networking on AWS that meant that one of our fileservers was slow. That may have affected your web app. It appears to be working now, so if your web app is still having trouble then it may be something else.

Staff

glenn
|
8703
posts
|

PythonAnywhere staff
|



Dec. 3, 2018, 3:43 p.m.

|
permalink

The app seems completely fine and I’m not getting an exceptions, etc. This seems to be coming from the server. Really the only impact seems to be that it is cluttering the log but if it is actually coming from my app that would be great to know.

deleted-user-3683187
|
37
posts
|



Dec. 3, 2018, 11:02 p.m.

|
permalink

Are they appearing alongside GeneratorExit messages? If so, this help page should explain what’s going on.

Staff

giles
|
11190
posts
|

PythonAnywhere staff
|



Dec. 4, 2018, 12:32 p.m.

|
permalink

Thanks, no. Just the OSError: write error message. Here’s an excerpt:

2018-11-26 18:58:20,040: OSError: write error
2018-11-26 19:11:08,110: OSError: write error
2018-11-26 20:04:12,727: OSError: write error
2018-11-26 21:13:56,156: OSError: write error
2018-11-26 21:13:56,156: OSError: write error
2018-11-26 21:14:21,486: OSError: write error
2018-11-26 22:03:23,262: OSError: write error
2018-11-26 22:05:18,174: OSError: write error
2018-11-27 03:25:17,531: OSError: write error
2018-11-27 03:47:52,955: OSError: write error
2018-11-27 05:41:26,548: OSError: write error
2018-11-27 11:00:31,114: OSError: write error
2018-11-27 12:10:22,251: OSError: write error
2018-11-27 12:33:31,353: OSError: write error
2018-11-27 12:33:37,890: OSError: write error
2018-11-27 15:53:30,449: OSError: write error
2018-11-27 18:59:08,227: OSError: write error

deleted-user-3683187
|
37
posts
|



Dec. 4, 2018, 5:22 p.m.

|
permalink

Interesting. Is it correlated with slow requests at the same time in the access log? Each request handled by your site has one line there, and at the end of the line there will be a response time.

Staff

giles
|
11190
posts
|

PythonAnywhere staff
|



Dec. 4, 2018, 5:38 p.m.

|
permalink

Thanks for the suggestion. I spot checked a few from Dec 02 (errors vs. access log) and some but not all of them correlate to longer requests. I am requesting data from an API that can take up to three seconds to respond, so my requests are occasionally that long.

During the longer requests I cache the results to disk and do a bunch of stuff with zero length files to provide locking functionality. I have some exception handling in there that could be hiding some errors. They all cover pretty obscure cases (lock file didn’t exist but another process created between the check and the touch with exist_ok=False). Given my traffic volume, I don’t expect there would be very many collisions.

In any event I have added debug messages to those three exception handlers to see if they correlate to the messages in the error log.

If so sorry for the hassle! I will let you know either way.

Chris

deleted-user-3683187
|
37
posts
|



Dec. 4, 2018, 6:28 p.m.

|
permalink

OK — looking forward to hearing the results of your investigations!

Staff

giles
|
11190
posts
|

PythonAnywhere staff
|



Dec. 4, 2018, 7:01 p.m.

|
permalink

It does not appear that the failed touch nor other exceptions are causing the message. As far as I can tell this doesn’t originate from my code, but I could certainly be missing something.

Here’s what I did:

  • Turned on a lot of log / debug messages.
  • Generated 12 requests / sec of test traffic to the site.
  • I can see the various scenarios getting exercised in the code, including the failed touch call and related exception handling that I was suspicious of.
  • I let the test traffic run for maybe 10 minutes. This generated approximately 7,000 requests (some take longer). On a given day the site only receives 300 — 700 page views so this was a good test.
  • Checked the error log and didn’t find any «OSError: write error» messages. I did see one from earlier but none during the test period.

Note also that for normal users I don’t do anything unique to their identity (I do basic auth for admin functions only). So generating traffic this way should be a fair simulation of normal traffic.

deleted-user-3683187
|
37
posts
|



Dec. 4, 2018, 7:28 p.m.

|
permalink

If it’s not coming from your code, it could be coming from the uWSGI middleware — that’s certainly where the OSError: write error messages combined with GeneratorExit messages that I mentioned earlier come from.

Maybe we can see if it’s just a different symptom of the same cause? If you were to make a request to the site with a super-short timeout — perhaps pick the slowest view — maybe we could see if the same error appears:

requests.get('https://yoursite.com/slow-view', timeout=0.1)

Staff

giles
|
11190
posts
|

PythonAnywhere staff
|



Dec. 5, 2018, 12:28 p.m.

|
permalink

I created a test script with a short timeout and ran it along side my test traffic generator. I caught the timeout exceptions and printed them. I can see a lot of timeouts.

I do see a lot of » OSError: write error». Apparently they are coming from the client
timeouts.

In the sever log I see the result of the timeout with errors like the ones below. I understand and expect these.

2018-12-06 05:47:44 Thu Dec  6 05:47:44 2018 - SIGPIPE: writing to a closed pipe/socket/fd (probably the client disconnected) on request / (ip 10.0.0.98) !!!
2018-12-06 05:47:44 Thu Dec  6 05:47:44 2018 - uwsgi_response_writev_headers_and_body_do(): Broken pipe [core/writer.c line 306] during GET / (10.0.0.98)

The strange thing I see a lot more ‘write error’s vs. the ‘writing to closed pipe’ errors above on my production site but now that I know what I am looking for I can find those that are there.

Thanks for your help tracking this down! I was fixated on this being a disk error. Didn’t think about pipes / client disconnects.

Chris

deleted-user-3683187
|
37
posts
|



Dec. 6, 2018, 10:50 p.m.

|
permalink

Excellent, glad you were able to get to the bottom of it!

Staff

giles
|
11190
posts
|

PythonAnywhere staff
|



Dec. 8, 2018, 5:42 p.m.

|
permalink

I have in server log:

2019-03-29 15:01:22 Fri Mar 29 15:01:22 2019 - SIGPIPE: writing to a closed pipe/socket/fd (probably the client disconnected) on request /1b3c4b5b-c9fc-495a-9032-ffab69d2f44d/rss/ (ip 10.0.0.162) !!!
2019-03-29 15:01:22 Fri Mar 29 15:01:22 2019 - uwsgi_response_writev_headers_and_body_do(): Broken pipe [core/writer.c line 306] during GET /1b3c4b5b-c9fc-495a-9032-ffab69d2f44d/rss/ (10.0.0.162)

In error log:

2019-03-29 15:01:22,987: OSError: write error

Also all my SQLite databases on pythonanywhere storage are locked (return apsw.BusyError: BusyError: database is locked when my Django website or scheduled task are trying to execute sql). The only way to unlock them: delete databases’ files and re-upload to the same folders again.

Everything worked fine before 28-03-2019 21:00. It was not any changes in my own code.
Any suggestions?

deleted-user-4722050
|
17
posts
|



March 29, 2019, 3:37 p.m.

|
permalink

I am seeing tons of these errors in my logs suddenly. Started around Fri Mar 29 15:27:37. Happened around the time performance issues arose on both my site and and their admin pages. Maybe networking issues on their side??

https://www.pythonanywhere.com/forums/topic/14059/

deleted-user-3683187
|
37
posts
|



March 29, 2019, 3:56 p.m.

|
permalink

hi there, I believe we corresponded over twitter. We had some performance problems on one of our servers. It should have recovered by now. We are investigating regarding root causes, and how to monitor and be alerted sooner etc.

Staff

conrad
|
4233
posts
|

PythonAnywhere staff
|



March 29, 2019, 5:34 p.m.

|
permalink

I am getting this, the request says pending and then times out after 4 secs (I think that it times out because the max request time is 4 secs) I have good wifi, why am I getting an OSError: write error

deleted-user-5590152
|
32
posts
|



May 14, 2019, 5:58 p.m.

|
permalink

The only timeout we have on our side is one of several minutes for website views. What URL are you getting the four-second timeout on?

Staff

giles
|
11190
posts
|

PythonAnywhere staff
|



May 15, 2019, 11:06 a.m.

|
permalink

Is there any way to disable logging of OSError: write error ?
The whole my log looks like this:

[....]
    2019-08-17 10:26:16,406: OSError: write error
    2019-08-17 10:27:16,391: OSError: write error
    2019-08-17 10:28:16,412: OSError: write error
    2019-08-17 10:29:16,168: OSError: write error
    2019-08-17 10:30:16,172: OSError: write error
    2019-08-17 10:31:16,387: OSError: write error
    2019-08-17 10:32:16,436: OSError: write error
    2019-08-17 10:33:16,400: OSError: write error
    2019-08-17 10:34:22,409: OSError: write error
    2019-08-17 10:35:22,410: OSError: write error
    2019-08-17 10:36:22,431: OSError: write error
[....]

And server log:

[....]
    2019-08-17 10:29:16 Sat Aug 17 10:29:16 2019 - uwsgi_response_write_body_do(): Broken pipe [core/writer.c line 429] during HEAD /25442dc2-d0e9-42e8-8296-46adc2f03008/rss/ (10.0.0.235)
    2019-08-17 10:30:16 Sat Aug 17 10:30:16 2019 - uwsgi_response_write_body_do(): Broken pipe [core/writer.c line 429] during HEAD /25442dc2-d0e9-42e8-8296-46adc2f03008/rss/ (10.0.0.235)
    2019-08-17 10:31:16 Sat Aug 17 10:31:16 2019 - uwsgi_response_write_body_do(): Broken pipe [core/writer.c line 429] during HEAD /25442dc2-d0e9-42e8-8296-46adc2f03008/rss/ (10.0.0.235)
    2019-08-17 10:32:16 Sat Aug 17 10:32:16 2019 - uwsgi_response_write_body_do(): Broken pipe [core/writer.c line 429] during HEAD /25442dc2-d0e9-42e8-8296-46adc2f03008/rss/ (10.0.0.235)
    2019-08-17 10:33:16 Sat Aug 17 10:33:16 2019 - uwsgi_response_write_body_do(): Broken pipe [core/writer.c line 429] during HEAD /25442dc2-d0e9-42e8-8296-46adc2f03008/rss/ (10.0.0.235)
    2019-08-17 10:34:22 Sat Aug 17 10:34:22 2019 - uwsgi_response_write_body_do(): Broken pipe [core/writer.c line 429] during HEAD /25442dc2-d0e9-42e8-8296-46adc2f03008/rss/ (10.0.0.235)
    2019-08-17 10:35:22 Sat Aug 17 10:35:22 2019 - uwsgi_response_write_body_do(): Broken pipe [core/writer.c line 429] during HEAD /25442dc2-d0e9-42e8-8296-46adc2f03008/rss/ (10.0.0.235)
    2019-08-17 10:36:22 Sat Aug 17 10:36:22 2019 - uwsgi_response_write_body_do(): Broken pipe [core/writer.c line 429] during HEAD /25442dc2-d0e9-42e8-8296-46adc2f03008/rss/ (10.0.0.235)
[....]

I can not see any useful information in my logs because they are totally overloaded with this error caused by one of my client’s connection. Everything is okay with my website responses.

deleted-user-4722050
|
17
posts
|



Aug. 17, 2019, 10:44 a.m.

|
permalink

You get that error when the client that is trying to reach your web app disconnects before the response has been fully sent. We have no way to disable it.

Staff

glenn
|
8703
posts
|

PythonAnywhere staff
|



Aug. 17, 2019, 5:12 p.m.

|
permalink

If you’re getting it after 4 seconds, then the client has a 4 second timeout set.

Staff

glenn
|
8703
posts
|

PythonAnywhere staff
|



Aug. 17, 2019, 5:13 p.m.

|
permalink

Same for me if i am trying to invoke any API getting «OSError: write error» in error.log, even the API is working fine from other server

VernitJain
|
2
posts
|



Aug. 4, 2020, 4:07 p.m.

|
permalink

You’re not clear on what you mean by invoke an API. Do you mean that you’re calling an API from your web app code or do you mean that you are treating your web app as an API and using a program to access it?

Staff

glenn
|
8703
posts
|

PythonAnywhere staff
|



Aug. 4, 2020, 4:49 p.m.

|
permalink

I had created an app for API and using the other app i am trying to call that.

VernitJain
|
2
posts
|



Aug. 9, 2020, 5:37 a.m.

|
permalink

Are you trying to access a URL on your site from inside a view on the same site? That will not work with a free account; you have just one process handling all requests to your site, which means that if it is busy handling one request, other requests will be queued up until it has finished handling it — so if it makes a request back to itself, that second request will be queued and never handled.

Staff

giles
|
11190
posts
|

PythonAnywhere staff
|



Aug. 9, 2020, 3:12 p.m.

|
permalink

I have the same problem «OSError: write error in error.log» during the POST request of a form.
The form takes 2 files and the error occurs when I use large files.
Do I need to change the UWSGI configuration or something like that?

deleted-user-8119985
|
4
posts
|



Nov. 7, 2020, 9:16 p.m.

|
permalink

How large are the files in question? How long is the page taking to return a response?

Staff

giles
|
11190
posts
|

PythonAnywhere staff
|



Nov. 8, 2020, 5:50 p.m.

|
permalink

Are excel files with something like 100k rows each one for example. Those files may have like 15MB. I have upgraded my account, I have now 4 workers and I’m fixing the code in order to work with multiple workers expecting that it solves the problem.
Am I going in a bad way?

deleted-user-8119985
|
4
posts
|



Nov. 11, 2020, 7:34 p.m.

|
permalink

No, writing your code so it can handle multiple workers is not a bad way to go. It may or may not solve the problem depending on what is actually causing the problem.

Staff

glenn
|
8703
posts
|

PythonAnywhere staff
|



Nov. 12, 2020, 10:39 a.m.

|
permalink

I have updated the code and it looks like it works better with more workers, but I have other problem now. Should I open a new thread on the forum?
This is the error log:

2020-11-13 09:15:24 Fri Nov 13 09:15:23 2020 — * * HARAKIRI ON WORKER 4 (pid: 27, try: 1) * *

2020-11-13 09:15:24 Fri Nov 13 09:15:23 2020 — HARAKIRI !!! worker 4 status !!!

2020-11-13 09:15:24 Fri Nov 13 09:15:23 2020 — HARAKIRI [core 0] 10.0.0.124 — POST /process/start/ since 1605258322

2020-11-13 09:15:24 Fri Nov 13 09:15:23 2020 — HARAKIRI !!! end of worker 4 status !!!

I have tested it locally and it works perfectly doing the same test.

Just in case: I’m working on my other account (user: DonLarry)

deleted-user-8119985
|
4
posts
|



Nov. 13, 2020, 9:25 a.m.

|
permalink

Those happen when you have a request that takes more than 5 min to respond. In that case, the worker will be killed and restarted. Check the endpoint (/process/start) to see why that was taking more than 5 min and work out how you can reduce its response time to below 5 min.

Staff

glenn
|
8703
posts
|

PythonAnywhere staff
|



Nov. 13, 2020, 10:46 a.m.

|
permalink

I have the same error. please how can I fix it?

deleted-user-9271322
|
22
posts
|



Jan. 7, 2021, 6:53 p.m.

|
permalink

FileNotFoundError: [Errno 2] No such file or directory: ‘/home/HTSanalysis/analytics_report/complete_analytics_report.pdf’
2021-01-06 15:26:12,153: OSError: write error
2021-01-06 15:34:56,373: OSError: write error
2021-01-06 16:46:52,236: OSError: write error
2021-01-06 16:46:52,253: OSError: write error
2021-01-06 16:46:52,255: OSError: write error
2021-01-06 16:46:52,256: OSError: write error
2021-01-06 16:46:52,259: OSError: write error
2021-01-06 16:49:02,679: OSError: write error
2021-01-06 16:51:52,545: OSError: write error
2021-01-06 17:04:24,205: OSError: write error
2021-01-06 17:32:02,338: OSError: write error
2021-01-07 00:02:59,461: OSError: write error

And the path exists. please how can I resolve this?

deleted-user-9271322
|
22
posts
|



Jan. 7, 2021, 6:55 p.m.

|
permalink

That error is from yesterday. Are you sure that the error is still happening and the cause of your problems?

Staff

glenn
|
8703
posts
|

PythonAnywhere staff
|



Jan. 7, 2021, 7:08 p.m.

|
permalink

Yes the error is still happening

deleted-user-9271322
|
22
posts
|



Jan. 7, 2021, 7:36 p.m.

|
permalink

I need to thoroughly test it before it goes live for people testing the app

deleted-user-9271322
|
22
posts
|



Jan. 7, 2021, 7:37 p.m.

|
permalink

Kindly advise on how to resolve this please

deleted-user-9271322
|
22
posts
|



Jan. 7, 2021, 8:15 p.m.

|
permalink

Even after adding 2 more workers, I still get the error, please help out

deleted-user-9271322
|
22
posts
|



Jan. 7, 2021, 8:38 p.m.

|
permalink

So I tested this locally and downloaded it countless times and it works, it is therefore from the server, please can you help. it gives server error here, please

deleted-user-9271322
|
22
posts
|



Jan. 8, 2021, 6:37 a.m.

|
permalink

Hi, I see the web app is disabled. Is the issue still to be resolved?

Staff

pafk
|
2441
posts
|

PythonAnywhere staff
|



Jan. 8, 2021, 9:20 a.m.

|
permalink

its not resolved

deleted-user-9271322
|
22
posts
|



Jan. 8, 2021, 5:43 p.m.

|
permalink

please help

deleted-user-9271322
|
22
posts
|



Jan. 8, 2021, 5:44 p.m.

|
permalink

Hello again, I tested this locally, it works locally but does not fully execute here and gives an OS Write error in the process of sending the file. please help out!

deleted-user-9271322
|
22
posts
|



Jan. 8, 2021, 6:12 p.m.

|
permalink

What is the error that you’re currently getting? The one that you posted yesterday was from the day before. Are you sure that the error that you’re currently getting is the same?

Staff

glenn
|
8703
posts
|

PythonAnywhere staff
|



Jan. 8, 2021, 6:22 p.m.

|
permalink

OSError: [Errno 116] Stale file handle
2021-01-08 01:16:48,997: OSError: write error
2021-01-08 18:15:52,677: OSError: write error

deleted-user-9271322
|
22
posts
|



Jan. 8, 2021, 6:28 p.m.

|
permalink

2021-01-08 18:15:52,677: OSError: write error

deleted-user-9271322
|
22
posts
|



Jan. 8, 2021, 6:38 p.m.

|
permalink

The OSError: write error lines are just there when a client disconnects before the response has been fully sent to the client. They can be an indicator that your site may be a little slow or that the timeouts in the client may be too short, but they do not affect the working of the site.

The Stale file handle error, however, may be an issue. Is there a traceback that precedes it. That should help you to track down what is causing that error.

Staff

glenn
|
8703
posts
|

PythonAnywhere staff
|



Jan. 8, 2021, 6:58 p.m.

|
permalink

There is no trace back

deleted-user-9271322
|
22
posts
|



Jan. 8, 2021, 7:51 p.m.

|
permalink

And yes you are right testing it locally shows it does not affect the working of the site. How do I resolve the timeout and the other issues? Kindly advise even if I need to increase the current facility

deleted-user-9271322
|
22
posts
|



Jan. 8, 2021, 7:52 p.m.

|
permalink

Here is one traceback before I send the file for download:
2021-01-08 19:18:10 Ready to send file for downloading -> This was a print statement to check if the file passes all executions and yes it does because it got here.

Then this->
2021-01-08 19:18:10 Fri Jan 8 19:18:10 2021 — SIGPIPE: writing to a closed pipe/socket/fd (probably the client disconnected) on request /_dash-update-component (ip 10.0.0.124) !!!

2021-01-08 19:18:10 Fri Jan 8 19:18:10 2021 — uwsgi_response_writev_headers_and_body_do(): Broken pipe [core/writer.c line 306] during POST /_dash-update-component (10.0.0.124)

deleted-user-9271322
|
22
posts
|



Jan. 8, 2021, 7:55 p.m.

|
permalink

Python threads support is disabled. You can enable it with —enable-threads

Please where do I enable the threads?

deleted-user-9271322
|
22
posts
|



Jan. 9, 2021, 8:30 a.m.

|
permalink

Unfortunately we don’t support threads in website code on PythonAnywhere.

Staff

giles
|
11190
posts
|

PythonAnywhere staff
|



Jan. 9, 2021, 4:04 p.m.

|
permalink

All

I was having this error but I noticed that I was not building a DataFrame correctly and I was trying to append an empty DataFrame to an existing csv in a folder.

I was about to ask in the forum when I realised the error

This may be a note to others with this issue. Beside the above, there could be a small issue in the code triggering this error

Beloved premium user

monitorcasalab
|
4
posts
|



March 23, 2021, 7:45 p.m.

|
permalink

Just to be sure — you were getting the writing to a closed pipe/socket/fd error as a result of that? That would be strange — I can’t see any way that the bug you describe could lead to that.

Staff

giles
|
11190
posts
|

PythonAnywhere staff
|



March 24, 2021, 11:34 a.m.

|
permalink

I’ve been getting a lot of write errors too.

2021-02-28 21:57:45,631: OSError: write error
2021-03-02 13:07:45,517: OSError: write error
2021-03-02 13:26:08,959: OSError: write error
2021-03-09 20:19:29,992: OSError: write error
2021-03-09 22:38:19,130: OSError: write error
2021-03-09 22:38:22,555: OSError: write error
2021-03-10 04:33:42,871: OSError: write error
2021-03-10 19:25:22,195: OSError: write error
2021-03-13 07:01:48,436: OSError: write error
2021-03-13 07:02:33,553: OSError: write error
2021-03-13 07:03:27,987: OSError: write error
2021-03-14 11:03:49,934: OSError: write error
2021-03-14 11:06:30,467: OSError: write error
2021-03-14 11:07:20,624: OSError: write error
2021-03-14 11:08:27,702: OSError: write error
2021-03-14 11:09:31,708: OSError: write error
2021-03-14 11:10:18,614: OSError: write error
2021-03-14 11:11:02,968: OSError: write error
2021-03-14 11:14:30,490: OSError: write error
2021-03-14 18:46:21,821: OSError: write error
2021-03-15 13:31:40,861: OSError: write error
2021-03-15 13:31:40,916: OSError: write error
2021-03-15 13:31:41,120: OSError: write error
2021-03-15 13:32:35,932: OSError: write error
2021-03-15 13:35:22,459: OSError: write error
2021-03-22 21:25:24,404: OSError: write error
2021-03-22 21:25:29,396: OSError: write error
2021-03-22 21:27:33,677: OSError: write error
2021-03-24 00:53:35,447: OSError: write error
2021-03-25 15:31:37,570: OSError: write error
2021-03-26 13:35:49,061: OSError: write error
2021-03-26 15:58:33,504: OSError: write error
2021-03-26 21:54:02,503: OSError: write error

Its a total pain because my app stops the reading the database and doesn’t resume until I have reloaded the site. That’s not a great look for my app and it means I’m shepherding it a lot of the time. Is there any method around it? I will accept that occasionally servers throw a write error, but I need a pythonic way around this issue. Any suggestions?

Thanks.

[formatted by admin]

Beloved premium user

Shematria
|
10
posts
|



March 27, 2021, 1:21 p.m.

|
permalink

As Glenn mentioned before:

The OSError: write error lines are just there when a client disconnects before the response has been fully sent to the client. They can be an indicator that your site may be a little slow or that the timeouts in the client may be too short, but they do not affect the working of the site.

So that error is a symptom not a cause.

If you take a look at your error logs, you’ll see bunch of errors related to database connections — if your code fails to connect with db and eventually the request gets a timeout, the error you see may be result of that.

Staff

pafk
|
2441
posts
|

PythonAnywhere staff
|



March 27, 2021, 7:56 p.m.

|
permalink

I think I’ve gotten to the bottom of the cause (fingers crossed). I was accessing the database a couple of times every run through with try & excepts, but I wasn’t giving each new request a unique cursor & connection name and I believe this was causing the intermittent problem.

I hope this helps someone else.
Thanks. :)

Beloved premium user

Shematria
|
10
posts
|



March 28, 2021, 4:10 a.m.

|
permalink

Excellent, glad you’ve worked that out (fingers crossed!) :)

Staff

pafk
|
2441
posts
|

PythonAnywhere staff
|



March 28, 2021, 8:38 a.m.

|
permalink

Hi team,

I’ve been working on my website just fine and then something happened I started getting the «Your webapp took a long time to reload.» error when trying to push the updated script onto the page. I then checked the error log and the only error it returned is the «OSError: write error» one.

To sanity check, I commented out all of my code and pasted the generic example from one of your tutorials which had worked fine for me before (https://blog.pythonanywhere.com/169/) but the problem persisted.

Could you please help me figure out what’s causing the OSError?

Thanks!

Beloved premium user

pukhova
|
7
posts
|



Jan. 2, 2023, 6:19 p.m.

|
permalink

Are you sure that the problem actually persisted and that you were not reading old error lines?

Staff

glenn
|
8703
posts
|

PythonAnywhere staff
|



Jan. 2, 2023, 7 p.m.

|
permalink

Thank you for your help — I think I’ve figured out the issue but not the solution yet. I’m importing a function from my own .py file which is also a scheduled task. The task log is not showing any issues (return code 0), however, the OSError shows in the log when I try importing a function from the scheduled .py file.

Is there a way to log the output of the scheduled task in a file and then just display the file on the webpage instead of calling the scheduled task script in the background every time? Sorry if this is basic, I’m new to this.

Btw, this was working for me just yesterday (i.e. importing and calling a function from my scheduled task script and getting the desired output), I’m not sure what happened.

Thanks!

Beloved premium user

pukhova
|
7
posts
|



Jan. 2, 2023, 9:10 p.m.

|
permalink

Scheduled tasks are not limited by short timeouts like stuff running in the context of web app responses to requests.

Staff

fjl
|
3651
posts
|

PythonAnywhere staff
|



Jan. 3, 2023, 9:32 a.m.

|
permalink

Sorry, I’m not sure what this means for my case. Could you please explain?

My scheduled task works and there are no timeout exceptions there. It’s when I try to import the results into my web app script that the issue arises.

Is there a blog post / tutorial that I could look at for how to use the output of my scheduled tasks in my web app script? Specifically, if there’s a way to store the output for a day until the next script runs and output it in the flask_app scipt.

Thank you!

Beloved premium user

pukhova
|
7
posts
|



Jan. 4, 2023, 12:34 a.m.

|
permalink

What kind of output is your scheduled task generating — is it something that could be served up straight to users of your site, like a CSV or some HTML? If so, you could use the static files system to serve it up.

Staff

giles
|
11190
posts
|

PythonAnywhere staff
|



Jan. 4, 2023, 11:37 a.m.

|
permalink

Содержание

  1. Forums
  2. OSError: Write Error
  3. Forums
  4. OSError: write error
  5. Forums
  6. many OSError: write error in web app error log
  7. Forums
  8. URGENT: OSError: write error, SIGPIPE and uwsgi_response_writev_headers_and_body_do()
  9. Forums
  10. OSError: write error in error.log

Forums

OSError: Write Error

Getting lots of OSError: Write Error many times in a day in my error log. Looking at old forum threads it appears to be causable by 2 things — attempting to touch wsgi.py and messing that up, or cookies failing to be set in a browser. Anyone have any clue why any of these could be happening?

show us the code that is producing the error

Those normally happen when a browser disconnects from your site while it’s trying to send back a response. All sites get a few of them from time to time, because people connect over unreliable networks (for example, mobile) and get disconnected, but if you’re getting a lot it might be a sign of a problem.

The most likely cause is that one or more of the views on your site are slow to return a response — then people will give up and click away to another page, or hit refresh, or do something else that will interrupt the connection. I’d suggest looking at the access log for the site — each request you get has a line in there, and they all have a response-time in seconds at the end. A quick and easy way to find the requests that were interrupted is to search for » 499 » — that’s space, 4, 9, 9, space — which will take you to lines with a 499 status code. 499 is a synthetic status code that nginx puts into the access logs when the browser disconnects.

Once you’ve found which views are running slowly enough that people are interrupting them, you can take a look at your code to try to work out why they’re running slowly.

This seems sort of right. Just today, I’ve gotten this many errors:

I’m worried that I can’t find what view specifically is causing the redirects — in addition, some are literally just 0.5 seconds response time — does this mean the website loaded in 0.5 seconds, or that they redirected away by going somewhere else after just 0.5 seconds. If it’s the former, there’s not much I can do about this right — they’re just leaving before my site’s loaded, right?

why do you think there is a redirect in your code? this should be user side behavior, where they click to go to a different page while your page is still loading. it could be going to a different page on your site. but as Giles said, check the 499 status codes in your access log to see what pages they are leaving from. if you don’t see a pattern- could it just be that you have high traffic and not enough webworkers to serve all your web requests quickly enough?

there are redirects — i redirect from a link whcih sets cookies to my index page. the 499 status codes just say they’re leaving as they load different static files — some the css, some the js, they’re leaving as those are loading. that would probably indicate that they just left while the website was loading right?

as for the high traffic — my google analytics says i have around 2k unique users, but the pythonanywhere stats say ive had 65k nonunique hits in the past 2 months — is there any more info on what the hits traffic means?

if you mean that there are external links that link/direct to your index page, then that shouldn’t matter her.

yes the 499s mean that your users are leaving before your front page has finished loading. You should setup static files mapping so that your core webservers don’t need to serve the static files and just needs to serve the base front page.

the reason for the hits is probably because each page might have multiple hits to multiple static assets. another reason to put them as a static file mapping.

if you are still seeing very slow speeds after fixing that, then you should consider putting a cdn in front of pythonanywhere, or adding more webworkers.

thanks for the advice! i’ll look into all of this

Источник

Forums

OSError: write error

I have a flask app that writes to a .txt file to keep track of blacklisted IPs. It works most of the time, but occasionally I get an error, «OSError: write error»

My confusion here is, the exact same code never has this issue on replit or when hosted locally, the issue seems to be exclusive to pythonanywhere. For now I’ve resolved it by adding error handling and having it retry if it fails, works fine, but why am I getting write errors with pythonanywhere in the first place?

(Extra note: I always close my files at the end of each function and I tested to see if it was crossover, but even when I que writing to the file to ensure there is no possible crossover, the error still occurs. Also, I know I could also switch to using SQL to store the IPs but I want to figure out what’s going on here regardless.)

Do the errors look like the ones mentioned in this help page? If so, they may be a result of your site running slowly — check out the page for more information.

Thanks for the speedy reply! Though I have seen «broken pipe» errors before, this specific situation I’m referring to seems completely isolated. Like this: «2022-04-03 02:35:49,428: OSError: write error» with nothing related to the error above or below it, just that one line. Repeats every once in a while, but I’ve only had it happen twice after posting that, so it’s not as frequent as before. Which. I upgraded my CPU seconds allowance since that post so you’re probably still right actually, I think I was in the tarpit at the time.

I think it could still be the site running slowly — or even just super-impatient people not waiting more than a second for a page, or people viewing the site from bad internet connections (where they might make a request, and then disconnect milliseconds later as their cellphone drops out of coverage).

TBH if you’re just seeing very rare errors like that, but aren’t seeing any complaints from people using your site, you can probably just treat it as «bad weather» — random noise in the logs due to the unreliability of the internet.

Oh, that’s probably it actually. One of my pages takes a couple seconds to load sending information, maybe users are just being impatient and slapping refresh mid-write. That would make a lot of sense come to think of it, especially since i haven’t gotten any complaints about it. Thanks for the help, you rock!

That would make sense, yes — glad we could help!

Источник

Forums

many OSError: write error in web app error log

I’m getting this error 5-6 times a day on my web error log:

Sometimes my app loads immediately, 2-3 seconds; sometimes it’s taking more like 12-13 seconds.

Any ideas how to fix this? FWIW it’s georgiaelectiontwitter.com

Normally that means that someone connected to your site, a page started loading, and then they disconnected before the page was sent back to them. That can happen for a number of reasons; a few a day on a reasonably popular site might just mean that a couple of people were visiting the page using mobile networks, or some other relatively unreliable connection, and they dropped out of coverage in between clicking on a link and your site sending the page back. If you get a very large number (which it doesn’t sound like you do) then it could be a sign that your site is running very slowly and people are getting impatient and going away while waiting for a page to load.

I’ve checked your site’s resource usage, and it does not look like its worker processes are overloaded with requests, so that’s good news — you don’t need to upgrade anything.

But the variation in page load speed sounds a bit odd. Which database are you using, if any — SQLite, MySQL or Postgres?

I too am hella-puzzled by the different load times.

And lol no my site is not popular by any means. Not a lot of traffic. But I’ve had more than one user say it takes 12-13 seconds to load. (I reckon those folks are clicking away and causing the write error) And I’ve had more than one say it’s basically immediate. For my own self too, the experience is mixed. Sometimes quick sometimes slow.

Maybe 2-3 days ago, I was trying to reload my app . I thought that would help. Sometimes the reload would time out. And a very few times when I tried to open the site in the browser, I got PA error page that said «Error Code: 502 backend»

Oh wait i just saw this on another thread; perhaps this is my problem:

SQLite firstly only allows one process to access it at any one time (which would explain why it’s slowing down other views), and secondly performs pretty badly when using networked filesystems like the one on PythonAnywhere, which would explain why it’s slow itself.

My app is just querying a database I have sitting in a directory, output.db

Yes, that does sound like it would be the problem — SQLite is a great database when you’re getting started, but it does become problematic if you’ve got concurrent users, especially if the database starts getting large. MySQL works much better, especially on PythonAnywhere.

Источник

Forums

URGENT: OSError: write error, SIGPIPE and uwsgi_response_writev_headers_and_body_do()

Hi, My site: www.jung.gg Has blown up on Reddit (https://www.reddit.com/r/leagueoflegends/comments/fdf1hr/a_new_analytics_site_for_popular_challenger/) and now I am getting the following errors:

2020-03-04 20:58:10,391: OSError: write error 2020-03-04 20:56:44 Wed Mar 4 20:56:44 2020 — SIGPIPE: writing to a closed pipe/socket/fd (probably the client disconnected) on request /result (ip 10.0.0.249) . 2020-03-04 20:56:44 Wed Mar 4 20:56:44 2020 — uwsgi_response_writev_headers_and_body_do(): Broken pipe [core/writer.c line 306] during POST /result (10.0.0.249)

Any urgent help would be appreciated!

That happens when a client disconnects while a response is being sent. If your website is experiencing high traffic and your views take a long time to render, then you may not have enough workers to handle the load, so requests spend a long time in the queue waiting for an available worker, so the users just see the page loading and leave the site.

Hello, so I’m also encountering similar problem while running my website. I hit API from my website and it will run a loop for 15 iterations, and then the web will display the processed data from the API. The data will be sent to MySQL database before displayed on the web. But I always get this message on my server logs when I hit the API and the error page is also appearing on my site, though all the data from 15 iterations are successfully transferred to the database.

But when I change the iteration on my API to 9 or 10 iteration, my website runs fine without showing the error page. Can anyone please help me fix this? Thank you

That message means that the client disconnected before the response has been effectively sent back. It’s not necessarily an error, rather a symptom. If you don’t want to see such messages in the logs, you may try to make processing in your app shorter (if they are caused by a short timeout on the client side) , but you can always get such message from time to time if the client disconnects.

Источник

Forums

OSError: write error in error.log

I see a lot of «OSError: write error» message in my error log. Been there for weeks.

I’m not getting any errors in my app although I am writing data to disk to cache it.

Is this coming from the server level? It appears so.

Should I be concerned? Any insight as to the source of the error?

We had some trouble with networking on AWS that meant that one of our fileservers was slow. That may have affected your web app. It appears to be working now, so if your web app is still having trouble then it may be something else.

The app seems completely fine and I’m not getting an exceptions, etc. This seems to be coming from the server. Really the only impact seems to be that it is cluttering the log but if it is actually coming from my app that would be great to know.

Are they appearing alongside GeneratorExit messages? If so, this help page should explain what’s going on.

Thanks, no. Just the OSError: write error message. Here’s an excerpt:

Interesting. Is it correlated with slow requests at the same time in the access log? Each request handled by your site has one line there, and at the end of the line there will be a response time.

Thanks for the suggestion. I spot checked a few from Dec 02 (errors vs. access log) and some but not all of them correlate to longer requests. I am requesting data from an API that can take up to three seconds to respond, so my requests are occasionally that long.

During the longer requests I cache the results to disk and do a bunch of stuff with zero length files to provide locking functionality. I have some exception handling in there that could be hiding some errors. They all cover pretty obscure cases (lock file didn’t exist but another process created between the check and the touch with exist_ok=False). Given my traffic volume, I don’t expect there would be very many collisions.

In any event I have added debug messages to those three exception handlers to see if they correlate to the messages in the error log.

If so sorry for the hassle! I will let you know either way.

OK — looking forward to hearing the results of your investigations!

It does not appear that the failed touch nor other exceptions are causing the message. As far as I can tell this doesn’t originate from my code, but I could certainly be missing something.

Here’s what I did:

  • Turned on a lot of log / debug messages.
  • Generated 12 requests / sec of test traffic to the site.
  • I can see the various scenarios getting exercised in the code, including the failed touch call and related exception handling that I was suspicious of.
  • I let the test traffic run for maybe 10 minutes. This generated approximately 7,000 requests (some take longer). On a given day the site only receives 300 — 700 page views so this was a good test.
  • Checked the error log and didn’t find any «OSError: write error» messages. I did see one from earlier but none during the test period.

Note also that for normal users I don’t do anything unique to their identity (I do basic auth for admin functions only). So generating traffic this way should be a fair simulation of normal traffic.

If it’s not coming from your code, it could be coming from the uWSGI middleware — that’s certainly where the OSError: write error messages combined with GeneratorExit messages that I mentioned earlier come from.

Maybe we can see if it’s just a different symptom of the same cause? If you were to make a request to the site with a super-short timeout — perhaps pick the slowest view — maybe we could see if the same error appears:

I created a test script with a short timeout and ran it along side my test traffic generator. I caught the timeout exceptions and printed them. I can see a lot of timeouts.

I do see a lot of » OSError: write error». Apparently they are coming from the client timeouts.

In the sever log I see the result of the timeout with errors like the ones below. I understand and expect these.

The strange thing I see a lot more ‘write error’s vs. the ‘writing to closed pipe’ errors above on my production site but now that I know what I am looking for I can find those that are there.

Thanks for your help tracking this down! I was fixated on this being a disk error. Didn’t think about pipes / client disconnects.

Excellent, glad you were able to get to the bottom of it!

I have in server log:

In error log:

Also all my SQLite databases on pythonanywhere storage are locked (return apsw.BusyError: BusyError: database is locked when my Django website or scheduled task are trying to execute sql). The only way to unlock them: delete databases’ files and re-upload to the same folders again.

Everything worked fine before 28-03-2019 21:00. It was not any changes in my own code. Any suggestions?

I am seeing tons of these errors in my logs suddenly. Started around Fri Mar 29 15:27:37. Happened around the time performance issues arose on both my site and and their admin pages. Maybe networking issues on their side??

hi there, I believe we corresponded over twitter. We had some performance problems on one of our servers. It should have recovered by now. We are investigating regarding root causes, and how to monitor and be alerted sooner etc.

I am getting this, the request says pending and then times out after 4 secs (I think that it times out because the max request time is 4 secs) I have good wifi, why am I getting an OSError: write error

The only timeout we have on our side is one of several minutes for website views. What URL are you getting the four-second timeout on?

Is there any way to disable logging of OSError: write error ? The whole my log looks like this:

I can not see any useful information in my logs because they are totally overloaded with this error caused by one of my client’s connection. Everything is okay with my website responses.

You get that error when the client that is trying to reach your web app disconnects before the response has been fully sent. We have no way to disable it.

If you’re getting it after 4 seconds, then the client has a 4 second timeout set.

Same for me if i am trying to invoke any API getting «OSError: write error» in error.log, even the API is working fine from other server

You’re not clear on what you mean by invoke an API. Do you mean that you’re calling an API from your web app code or do you mean that you are treating your web app as an API and using a program to access it?

I had created an app for API and using the other app i am trying to call that.

Are you trying to access a URL on your site from inside a view on the same site? That will not work with a free account; you have just one process handling all requests to your site, which means that if it is busy handling one request, other requests will be queued up until it has finished handling it — so if it makes a request back to itself, that second request will be queued and never handled.

I have the same problem «OSError: write error in error.log» during the POST request of a form. The form takes 2 files and the error occurs when I use large files. Do I need to change the UWSGI configuration or something like that?

How large are the files in question? How long is the page taking to return a response?

Are excel files with something like 100k rows each one for example. Those files may have like 15MB. I have upgraded my account, I have now 4 workers and I’m fixing the code in order to work with multiple workers expecting that it solves the problem. Am I going in a bad way?

No, writing your code so it can handle multiple workers is not a bad way to go. It may or may not solve the problem depending on what is actually causing the problem.

I have updated the code and it looks like it works better with more workers, but I have other problem now. Should I open a new thread on the forum? This is the error log:

2020-11-13 09:15:24 Fri Nov 13 09:15:23 2020 — * * HARAKIRI ON WORKER 4 (pid: 27, try: 1) * *

2020-11-13 09:15:24 Fri Nov 13 09:15:23 2020 — HARAKIRI . worker 4 status .

2020-11-13 09:15:24 Fri Nov 13 09:15:23 2020 — HARAKIRI [core 0] 10.0.0.124 — POST /process/start/ since 1605258322

2020-11-13 09:15:24 Fri Nov 13 09:15:23 2020 — HARAKIRI . end of worker 4 status .

I have tested it locally and it works perfectly doing the same test.

Just in case: I’m working on my other account (user: DonLarry)

Those happen when you have a request that takes more than 5 min to respond. In that case, the worker will be killed and restarted. Check the endpoint ( /process/start ) to see why that was taking more than 5 min and work out how you can reduce its response time to below 5 min.

I have the same error. please how can I fix it?

Источник

загрузил телеграм эхо бота на pythonanywhere
выдает ошибку

(venv) 08:28 ~/bott $ python bot1.py 
Goodbye!
Traceback (most recent call last):
  File "/home/akshin17/venv/lib/python3.8/site-packages/aiohttp/connector.py", line 969, in _wrap_create_connection
    return await self._loop.create_connection(*args, **kwargs)  # type: ignore  # noqa
  File "/usr/lib/python3.8/asyncio/base_events.py", line 1017, in create_connection
    raise exceptions[0]
  File "/usr/lib/python3.8/asyncio/base_events.py", line 1002, in create_connection
    sock = await self._connect_sock(
  File "/usr/lib/python3.8/asyncio/base_events.py", line 916, in _connect_sock
    await self.sock_connect(sock, address)
  File "/usr/lib/python3.8/asyncio/selector_events.py", line 485, in sock_connect
    return await fut
  File "/usr/lib/python3.8/asyncio/selector_events.py", line 490, in _sock_connect
    sock.connect(address)
OSError: [Errno 101] Network is unreachable

The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/home/akshin17/venv/lib/python3.8/site-packages/aiogram/bot/api.py", line 139, in make_request
    async with session.post(url, data=req, **kwargs) as response:
  File "/home/akshin17/venv/lib/python3.8/site-packages/aiohttp/client.py", line 1117, in __aenter__
    self._resp = await self._coro
  File "/home/akshin17/venv/lib/python3.8/site-packages/aiohttp/client.py", line 520, in _request
    conn = await self._connector.connect(
  File "/home/akshin17/venv/lib/python3.8/site-packages/aiohttp/connector.py", line 535, in connect
    proto = await self._create_connection(req, traces, timeout)
  File "/home/akshin17/venv/lib/python3.8/site-packages/aiohttp/connector.py", line 892, in _create_connection
    _, proto = await self._create_direct_connection(req, traces, timeout)
  File "/home/akshin17/venv/lib/python3.8/site-packages/aiohttp/connector.py", line 1051, in _create_direct_connection
    raise last_exc
  File "/home/akshin17/venv/lib/python3.8/site-packages/aiohttp/connector.py", line 1020, in _create_direct_connection
    transp, proto = await self._wrap_create_connection(
  File "/home/akshin17/venv/lib/python3.8/site-packages/aiohttp/connector.py", line 975, in _wrap_create_connection
    raise client_error(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host api.telegram.org:443 ssl:default [Network is unreachable]
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "bot1.py", line 21, in <module>
    executor.start_polling(dp, skip_updates=True)
  File "/home/akshin17/venv/lib/python3.8/site-packages/aiogram/utils/executor.py", line 41, in start_polling
    executor.start_polling(reset_webhook=reset_webhook, timeout=timeout, relax=relax, fast=fast)
  File "/home/akshin17/venv/lib/python3.8/site-packages/aiogram/utils/executor.py", line 309, in start_polling
    loop.run_until_complete(self._startup_polling())
  File "/usr/lib/python3.8/asyncio/base_events.py", line 608, in run_until_complete
    return future.result()
  File "/home/akshin17/venv/lib/python3.8/site-packages/aiogram/utils/executor.py", line 360, in _startup_polling
    await self._welcome()
  File "/home/akshin17/venv/lib/python3.8/site-packages/aiogram/utils/executor.py", line 350, in _welcome
    user = await self.dispatcher.bot.me
  File "/home/akshin17/venv/lib/python3.8/site-packages/aiogram/bot/bot.py", line 29, in me
    setattr(self, '_me', await self.get_me())
  File "/home/akshin17/venv/lib/python3.8/site-packages/aiogram/bot/bot.py", line 217, in get_me
    result = await self.request(api.Methods.GET_ME, payload)
  File "/home/akshin17/venv/lib/python3.8/site-packages/aiogram/bot/base.py", line 208, in request
    return await api.make_request(self.session, self.server, self.__token, method, data, files,
  File "/home/akshin17/venv/lib/python3.8/site-packages/aiogram/bot/api.py", line 142, in make_request
    raise exceptions.NetworkError(f"aiohttp client throws an error: {e.__class__.__name__}: {e}")
aiogram.utils.exceptions.NetworkError: Aiohttp client throws an error: ClientConnectorError: Cannot connect to host api.telegram.org:443 ssl:default [Network is u
nreachable]

как избавиться от ошибки

мое приложение использует nginx, с uWSGI на стороне сервера. Когда я делаю большой запрос (с временем отклика > 4s), появляется следующее:

SIGPIPE: writing to a closed pipe/socket/fd (probably the client
    disconnected) on request _URL_ (ip XX.XX.XX.XX) !!!

uwsgi_response_writev_headers_and_body_do(): Broken pipe
    [core/writer.c line 287] during GET _URL_ (XX.XX.XX.XX)

OSError: write error

кажется, что uWSGI пытается писать в потоке, но этот поток уже закрыт.
Когда я проверяю журнал nginx (ошибка.log):

upstream prematurely closed connection while reading response
    header from upstream ...

конечно, мой клиент (клиент REST или браузер) получает ошибку 502.

Я всегда получаю эту ошибку после ~4s.

тем не менее, я не знаю, как предотвратить эту проблему.
Я попытался установить некоторые параметры в конфигурационном файле nginx:

location my_api_url {
    [...]
    uwsgi_buffer_size 32k;
    uwsgi_buffers 8 32k;
    uwsgi_busy_buffers_size 32k;

    uwsgi_read_timeout 300;
    uwsgi_send_timeout 300;

    uwsgi_connect_timeout 60;
}

но проблема все еще здесь.
Я также попытался установить эти параметры в файле конфигурации uWSGI (wsgi.ini-файл):

buffer-size=8192
ignore-sigpipe=true
ignore-write-errors=true

прежде чем пытаться оптимизировать время отклика, я надеюсь, что эта проблема имеет решение. Я не нахожу никого, кто работает на другой должности. Я работаю с большим количеством данных, поэтому время моего ответа в некоторых случаях будет между 4-10s.

надеюсь, вы можете помочь я:)

большое спасибо заранее.

1 ответов


может быть так, что при загрузке вещей вы используете фрагментированную кодировку.
Существует опция uWSGI
--chunked-input-timeout,
что по умолчанию-4 секунды (это по умолчанию
к значению --socket-timeout, что составляет 4 секунды).

хотя проблема теоретически может лежать где-то еще, я предлагаю вам попробовать
вышеупомянутые варианты. Кроме того, раздражающие исключения-причина, по которой у меня есть

ignore-sigpipe=true
ignore-write-errors=true
disable-write-exception=true

в моей конфигурации uWSGI (обратите внимание, что я предоставляю 3 варианта, а не 2):

  • ignore-sigpipe делает uWSGI не показывать ошибки SIGPIPE;
  • ignore-write-errors делает его не показывать ошибки с
    например,uwsgi_response_writev_headers_and_body_do;
  • disable-write-exception предотвращает
    OSError поколение пишет.

WebAug 16, 2020 OSError is a built-in exception in Python and serves as the error class for the os module, which is raised when an os specific system function returns a system …
From geeksforgeeks.org
Estimated Reading Time 40 secs
See details »


UWSGI: OSERROR: WRITE ERROR DURING GET REQUEST

WebNov 24, 2019 From the Tags I notice that you are using nginx+uwsgi configuration, there are multiple ways to solve this : Find your most time consuming request and match it …
From stackoverflow.com
Reviews 1
See details »


OSERROR: WRITE ERROR : FORUMS : PYTHONANYWHERE

WebOct 10, 2019 A quick and easy way to find the requests that were interrupted is to search for » 499 » — that’s space, 4, 9, 9, space — which will take you to lines with a 499 status …
From pythonanywhere.com
See details »


HOW CAN I FIX AN `OSERROR: FILE ERROR: BAD INPUT FILE` IN RDKIT WITH …

WebApr 8, 2019 It takes a .sdf file with data about chemicals molecules as an argument, but then RDkit throw an error: OSError: File error: Bad input file file.sdf. I followed the …
From stackoverflow.com
See details »


WHEN SHOULD I USE WRITE-ERROR VS. THROW? TERMINATING VS.

WebFeb 15, 2012 @Gisli: It’s important to note that return does not return to the caller in the process block of an (advanced) function; instead, it proceeds to the next input object in …
From stackoverflow.com
See details »


OSERROR: WRITE ERROR IN ERROR.LOG : FORUMS : PYTHONANYWHERE

WebJan 4, 2023 2019-03-29 15:01:22,987: OSError: write error Also all my SQLite databases on pythonanywhere storage are locked (return apsw.BusyError: BusyError: database is …
From pythonanywhere.com
See details »


PYTHON — UWSGI THROWS IO ERROR CAUSED BY …

WebJan 9, 2013 This error means that the client has closed the connection before uWSGI/Django sends the response. It is generally caused by a timeout in the browser or …
From stackoverflow.com
See details »


[SOLVED] OSERROR ERRNO22 INVALID ARGUMENT — PYTHON POOL

WebMay 23, 2021 OSError is the type of error in OSError : [errno22] invalid argument. OSError is an error class for the OS module. It is a built-in exception in python, which is …
From pythonpool.com
See details »


HOW TO CATCH OSERROR EXCEPTION IN PYTHON? — TUTORIALSPOINT.COM

WebSep 27, 2019 OSError serves as the error class for the os module, and is raised when an error comes back from an os-specific function. We can re-write the given code as …
From tutorialspoint.com
See details »


FIRST TWO TRANSACTIONS AFTER I2C.INIT() RAISE OSERROR -1010 #474

WebOct 15, 2017 i2c. init (scl = pin0, sda = pin1) # doesn’t actually change the pins! i2c. scan # this will call i2c_reset() which will change the pins i2c. init # doesn’t actually reset the …
From github.com
See details »


OSERROR: FAILED TO WRITE DATA #60 — GITHUB

WebNov 21, 2014 OSError: failed to write data · Issue #60 · GrahamDumpleton/mod_wsgi · GitHub. GrahamDumpleton mod_wsgi Public. Notifications. Fork. Star. Code. Issues. …
From github.com
See details »


OSERROR IN PYTHON? — STACK OVERFLOW

WebMar 4, 2015 However, if not: I get a nasty OSError. It doesn’t go to the else block, it just gives me OSError. Even with the try/except block, it doesn’t process correctly. It will go …
From stackoverflow.com
See details »


UWSGI OSERROR: WRITE ERROR · ISSUE #264 · OPEN-CONTRACTING/DEPLOY

WebApr 26, 2021 uWSGI OSError: write error #264 Closed jpmckinney opened this issue on Apr 26, 2021 · 2 comments Member jpmckinney commented on Apr 26, 2021 • edited 4 …
From github.com
See details »


HOW TO FIX UWSGI «OSERROR: WRITE ERROR» — STUMBLES

WebSep 21, 2021 To prevent the (harmless) errors in the uWSGI log, you need all three of these lines in your uWSGI config: ignore-sigpipe ignore-write-errors disable-write …
From stumbles.id.au
See details »


Related Search


Понравилась статья? Поделить с друзьями:
  • Python35 dll ошибка
  • Qserialport timeout error
  • Python яндекс практикум обработка ошибок
  • Qsave ошибка сохранения копии проектных данных неверное имя файла проекта
  • Qrator http 431 поля заголовка запроса слишком велики как исправить