eliotz
eliotz

Reputation: 119

AttributeError: module 'socket' has no attribute 'setblocking'

I'm trying to use 'non-blocked socket' for a Python project

(see previous question if anyone has a better answer : How to use a socket without waiting in python )

I saw that people on the site suggested using the command: socket.setblocking ()

But when I run the program it crashes, and the error is recorded:

 AttributeError: module 'socket' has no attribute 'setblocking'

How can I fix this?

And is there another way?

Upvotes: 1

Views: 1196

Answers (1)

Paul P
Paul P

Reputation: 3917

It looks like you are trying to call setblocking() on the module called socket rather than on the object called socket.

Change your code to something like:

import socket

s = socket.socket(...)

s.setblocking(...)

Upvotes: 3

Related Questions