4. Examples

4.10. Multiprocessing

You can increase the number of workers to process table data via max_workers attribute of a writer. The more max_workers the less processing time when tabular data is large and the execution environment has available cores.

If you increase max_workers larger than one, recommend using main guarded as follows to avoid problems caused by multi-processing:

from multiprocessing import cpu_count
import pytablewriter as ptw

def main():
    writer = ptw.MarkdownTableWriter()
    writer.max_workers = cpu_count()
    ...

if __name__ == "__main__":
    main()