Skip to Content
Mastering Python for Networking and Security
book

Mastering Python for Networking and Security

by José Manuel Ortega
September 2018
Intermediate to advanced
426 pages
10h 46m
English
Packt Publishing
Content preview from Mastering Python for Networking and Security

Creating ThreadPoolExecutor

We can define our ThreadPoolExecutor object with the init constructor:

executor = ThreadPoolExecutor(max_workers=5)

We can create our ThreadPoolExecutor if we pass to the constructor the maximum number of workers as the parameter. In this example, we have defined five as the maximum number of threads, which means that this group of subprocesses will only have five threads working simultaneously.

In order to use our ThreadPoolExecutor, we can call the submit() method, which takes a function for executing that code in an asynchronous way as a parameter: executor.submit(myFunction())

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering Python for Networking and Security - Second Edition

Mastering Python for Networking and Security - Second Edition

José Manuel Ortega
Python for Cybersecurity

Python for Cybersecurity

Howard E. Poston, III

Publisher Resources

ISBN: 9781788992510Supplemental Content