Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python threadpool map exception

from concurrent.futures import ThreadPoolExecutor, as_completed

def div_zero(x):
    return x / 0

with ThreadPoolExecutor(max_workers=4) as executor:
    futures = executor.map(div_zero, range(4))
    for future in as_completed(futures): print(future)
      
  Traceback (most recent call last):
  File "...futures_exceptions.py", line 11, in <module>
    for future in as_completed(futures):
  File "...python3.3/concurrent/futures/_base.py", line 193, in as_completed
    with _AcquireFutures(fs):
  File "...python3.3/concurrent/futures/_base.py", line 142, in __init__
    self.futures = sorted(futures, key=id)
  File "...python3.3/concurrent/futures/_base.py", line 546, in result_iterator
    yield future.result()
  File "...python3.3/concurrent/futures/_base.py", line 392, in result
    return self.__get_result()
  File "...python3.3/concurrent/futures/_base.py", line 351, in __get_result
    raise self._exception
  File "...python3.3/concurrent/futures/thread.py", line 54, in run
    result = self.fn(*self.args, **self.kwargs)
  File "...futures_exceptions.py", line 7, in div_zero
    return x / 0
ZeroDivisionError: division by zero
Comment

PREVIOUS NEXT
Code Example
Python :: how to create sets in python 
Python :: ENCAPSUALTION 
Python :: How determine if a number is even or odd using bitwise operator 
Python :: pandas reverse explode 
Python :: c vs python speed 
Python :: double linked list python 
Python :: excel win32com select multiple cells in a row or column 
Python :: Python Tkinter Menu Widget Syntax 
Python :: dataset to list python 
Python :: Comparing Sets with isdisjoint() Function in python 
Python :: how to track exact location of a phone number in python 
Python :: Unable to locate package python-obexftp 
Python :: python keyword search engine 
Python :: It appears you are missing some prerequisite to build the package from source 
Python :: python show difference between two strings and colorize it 
Python :: Example of inheritance and constructor in subclass 
Python :: Sending Data in Unstructured File Form 
Python :: multiplying float variables python and print 
Python :: using ipfn in python 
Python :: twitter python 
Python :: Using iterable unpacking operator * With unique values 
Python :: how to run another python file in python 
Python :: spark sparsevector to list 
Python :: machine earning to predict sentimentanalysis python 
Python :: pie chart add outline python 
Python :: rotate an image python keras 
Python :: pip unknown command import 
Python :: como inserir regras usg pelo prompt 
Python :: Syntax Closing a File in python 
Python :: Python String Membership 
ADD CONTENT
Topic
Content
Source link
Name
2+2 =