[Chennaipy] Doubt on creating threads in python

Yacko Abrams yackoa at gmail.com
Tue May 29 02:02:18 EDT 2018


Hi Rohit,
Threads would be slightly slower than multiprocessing. You might have
issues with sharing variables or GIL. Hence usually multiprocessing is
preferred over threads in python.

So to answer your question, you can use the second method
login_threadpool() shown in the code shared, which uses multiprocessing.

(That being said the first method that uses threads could work just fine
for most purposes)

Regards,
Yacko


On Tue, 29 May 2018, 11:23 am Rohit Kottamasu, <rohit.topmaster at gmail.com>
wrote:

> Hey,
> I have written a login script in python for logging into a remote SSH.
> That is running successfully. I wrote the code in two ways using thread and
> threadpool. But, I'm unable to understand the exact difference of these two
> executions. I also want to know which function is more preferred.
> (login_thread or login_threadpool). What are the advantages and the
> drawbacks?
>
> Thanks
> --
> Regards,
> Rohit Kottamasu,
> B.tech Computer Science,
> Junior Year
> Shiv Nadar University
> Blog: https://inkmethoughts.blogspot.in/
> _______________________________________________
> Chennaipy mailing list
> Chennaipy at python.org
> https://mail.python.org/mailman/listinfo/chennaipy
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/chennaipy/attachments/20180529/99c00a49/attachment.html>


More information about the Chennaipy mailing list