Code Monkey home page Code Monkey logo

python-threading's Introduction

Build Fast and Efficient Python Applications Using Threads

Source code for the O'Reilly live online training with Lee Gaines.

We will use a Python3 Docker image to run the code. Assuming you have installed Docker, navigate to the src/threads directory of this repo, then build the image with the following command:

docker build -t py3-threads .

To access the shell, run a container using this command:

docker run -it py3-threads bash

All of the source code will be located in the /src directory in the container. To sync this directory with your working directory when you run the container, use this command:

docker run -it --mount type=bind,source=$$(pwd),target=/src py3-threads bash

If you have make you can use the following commands to automate the build and run commands:

make build
make run

Tips and Notes

  • To view the threads as a program is running: htop -> F2 -> Show custom thread names
  • Show information about the current thread: threading.current_thread()
  • Green threads are scheduled by the Python process, as opposed to a system-level thread scheduled by the OS.

python-threading's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.