tags:

views:

42

answers:

1

It seem what i can do fast crawler with python in two ways:

  1. thread pool with block sockets

  2. non block sockets select,asyncore,etc..

i thnk where is no real need in thread here, and solution #2 better.

which is better and why?

+1  A: 

Twisted is usually preferred to asyncore. It is an asynchronous I/O framework that can also work with thread pools.

In Python, you should prefer asynchronous IO to threads, simply because threads are a second class citizen in its canonical implementation (CPython) due to GIL.

Alex B
I am intrested in implementation on low level at this moment, how twisted do it internaly with asyncore?
Evg
@Evg Twisted and asyncore are two different implementations, they are not related.
Alex B
i understand) i mean what twisted internally can do it only by threads or asyncore at low level, i am right? And my question what better threads with blocking sockets or asyncore.
Evg
or as you say "Twisted and asyncore are two different implementations" how twisted do it internaly? i mean python interface to non blocking sockets at low level used by twisted.
Evg
@Evg seems from the source it uses `select` module, which uses platform-specific polling mechanism (epoll, kqueue, etc).
Alex B
thanx for you help, i edit question according to you, what do you think about prefered solution #1 or #2?
Evg
@Evg I've updated the answer.
Alex B