Forums

BlockingIOError: [Errno 11] write could not complete without blocking

Please help. I see the following error: BlockingIOError: [Errno 11] write could not complete without blocking

I am using chatterbot along with flask. Is this because of the time it takes to train.Thanks.

What is your code doing at the point that it raises the error? Could you post the full stack trace?

same problem

What's the block of code causing this error? and could you provide the full stack trace?

I have the same problem. When the button is clicked, data is generated based on other data already in the database. After that, the received data is stored in the database.

An error occurs when there are too many initial data, on the basis of which operations are performed

# 012 [Errno 11] could not complete without blocking

can we get the full error stack trace please?

Hello,<br> I am also facing the same issue with my django application. I am using for loop for the list items (can have 5000 items in the list). then for each item i am calling one function which will perform some operation on that item. With approx 1500 items list my site is giving error "server error 500". for the debug purpose I have put print statements but now I am getting error "BlockingIOError: [Errno 11] write could not complete without blocking" error stack is as follows, <pre> Traceback (most recent call last): File "/home/nilchoud/.virtualenvs/shree/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner response = get_response(request) File "/home/nilchoud/.virtualenvs/shree/lib/python3.6/site-packages/django/core/handlers/base.py", line 126, in _get_response response = self.process_exception_by_middleware(e, request) File "/home/nilchoud/.virtualenvs/shree/lib/python3.6/site-packages/django/core/handlers/base.py", line 124, in _get_response response = wrapped_callback(request, callback_args, *callback_kwargs) File "/home/nilchoud/cobol/pgm/views.py", line 141, in pgmindex print("{}".format(i[0])) BlockingIOError: [Errno 11] write could not complete without blocking </pre>

Please let me know how to solve this issue. Thank you..!

Just printing does not go anywhere useful. Try printing to stderr and see if that helps.

Hi, thanks for reply. Now i have few questions, 1. With print i can see the printed information in server log, is print statement causing this error. 2. If simple print causing error, please provide syntax to print data to stderr. 3. What is the exact meaning of this error.. 4. Why I am not able to process list with 1500 items on pythonwnywhere server, where as if I run same program locally with same data it terminates correctly but my site throws server error 500. sorry for these many questions please help. Thank you

  1. OK. Perhaps you've done something in your logging config to route stdout to a log file.
  2. print("the thing", file=sys.stderr)
  3. It means that Django wants to write to a non-blocking output stream, but the stream that you are trying to write to is a blocking stream.
  4. There's no way for me to tell. Check you logs for tracebacks that you can use to debug it.

Hi, thank you for your help.. this issue is resolve now.

I was using chatterbot along with flask. And had the same issue when I added the following code:

# Create a new trainer for the chatbot
trainer = ChatterBotCorpusTrainer(bot)

# Train the chat bot based on the english corpus
trainer.train("chatterbot.corpus.english")

Here are the error message:

2019-10-29 03:35:10,670: Error running WSGI application 
2019-10-29 03:35:10,671: BlockingIOError: [Errno 11] write could not complete without blocking 
2019-10-29 03:35:10,671: File "/var/www/xxx_pythonanywhere_com_wsgi.py", line 111, in <module> 
2019-10-29 03:35:10,671: from flask_app import app as application # noqa 
2019-10-29 03:35:10,671: 
2019-10-29 03:35:10,672: File "/home/xxx/dev/my_app/flask_app.py", line 6, in <module> 
2019-10-29 03:35:10,672: app=create_app() 
2019-10-29 03:35:10,672: 
2019-10-29 03:35:10,672: File "/home/xxx/dev/my_app/app/init.py", line 49, in create_app 
2019-10-29 03:35:10,672: from .views import register_blueprints 
2019-10-29 03:35:10,672: 
2019-10-29 03:35:10,672: File "/home/xxx/dev/my_app/app/views/init.py", line 4, in <module> 
2019-10-29 03:35:10,672: from .main_views import main_blueprint 
2019-10-29 03:35:10,672: 
2019-10-29 03:35:10,673: File "/home/xxx/dev/my_app/app/views/main_views.py", line 28, in <module> 
2019-10-29 03:35:10,673: trainer.train("chatterbot.corpus.english") 
2019-10-29 03:35:10,673: 
2019-10-29 03:35:10,673: File "/home/xxx/.virtualenvs/my_app/lib/python3.7/site-packages/chatterbot/trainers.py", line 149, in train 
2019-10-29 03:35:10,673: len(corpus) 
2019-10-29 03:35:10,673: 
2019-10-29 03:35:10,673: File "/home/xxx/.virtualenvs/my_app/lib/python3.7/site-packages/chatterbot/utils.py", line 203, in print_progress_bar 
2019-10-29 03:35:10,673: sys.stdout.write("\r{0}: [{1}] {2}%".format(description, hashes + spaces, int(round(percent * 100))))

Please help to resolve it.

[edit by admin: formatting]

using ChatterBot v1.0.1

It looks like ChatterBot is trying to print out a large amount of stuff while you train it. The way to fix the error is just to stop it from printing that out. Right now, you probably have a line that looks something like this:

bot.set_trainer(ChatterBotCorpusTrainer)

All you need to do to stop it from printing out so much stuff is change that to this:

bot.set_trainer(ChatterBotCorpusTrainer, show_training_progress=False)

hiii im getting this error! BlockingIOError: [Errno 11] write could not complete without blocking File "/var/www/xxx_pythonanywhere_com_wsgi.py", line 15, in <module> from mytemplateserver import app as application

while running chatbot application. Kindly help me!!

Is your chatbot application using ChatterBot? If so, have you changed the way you set the trainer as described in the previous post on this thread?

yes i'm using chatter bot the new version has this line

trainer.train("chatterbot.corpus.english")

the new version has no set_trainer.

Could you post all of the code that you have up to the trainer.train line?

.

chatbot = ChatBot('Botter')


trainer = ChatterBotCorpusTrainer(chatbot)


 trainer.train("chatterbot.corpus.english")


@app.route("/get")
def get_bot_response():
    userText = request.args.get('msg')
    return str(chatbot.get_response(userText))

[edit by admin: formatting]

OK -- try replacing this line:

trainer = ChatterBotCorpusTrainer(chatbot)

...with this:

trainer = ChatterBotCorpusTrainer(chatbot, show_training_progress=False)

wow that worked! thank you

Hello, I have the same error with my scrape application, please help!

Original code:

from flask import Flask
from scrape import Scraper


app = Flask(__name__)

quotes = Scraper()



@app.get("/{cat}")
async def read_item(cat):
      return quotes.scrapedata(cat)

.

2022-12-30 08:02:39,947: Error running WSGI application
2022-12-30 08:02:39,954: BlockingIOError: [Errno 11] write could not complete without blocking
2022-12-30 08:02:39,954:   File "/var/www/zett_pythonanywhere_com_wsgi.py", line 16, in <module>
2022-12-30 08:02:39,954:     from flask_app import app as application  # noqa
2022-12-30 08:02:39,954: 
2022-12-30 08:02:39,954:   File "/home/zett/mysite/flask_app.py", line 9, in <module>
2022-12-30 08:02:39,954:     from scrape import Scraper
2022-12-30 08:02:39,954: 
2022-12-30 08:02:39,955:   File "/home/zett/mysite/scrape.py", line 41, in <module>
2022-12-30 08:02:39,955:     quotes.scrapedata('cat')
2022-12-30 08:02:39,955: 
2022-12-30 08:02:39,955:   File "/home/zett/mysite/scrape.py", line 34, in scrapedata
2022-12-30 08:02:39,955:     print(file_urs)
2022-12-30 08:02:39,955: ***************************************************
2022-12-30 08:02:39,955: If you're seeing an import error and don't know why,
2022-12-30 08:02:39,955: we have a dedicated help page to help you debug:

[edit by admin: formatting]

It seems likely that it's the same problem; something inside the scrape library that you're using is printing out a very large amount of stuff. If you look at the docs for that library, hopefully you'll be able to find a way to stop it from doing that.