معرفی شرکت ها


Flask-Threads-0.1.0


Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر
Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر
Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر
Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر
Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر

توضیحات

A helper library to work with threads within Flask applications.
ویژگی مقدار
سیستم عامل -
نام فایل Flask-Threads-0.1.0
نام Flask-Threads
نسخه کتابخانه 0.1.0
نگهدارنده []
ایمیل نگهدارنده []
نویسنده Alexey Minakov
ایمیل نویسنده a@spb.host
آدرس صفحه اصلی https://github.com/sintezcs/flask-threads.git
آدرس اینترنتی https://pypi.org/project/Flask-Threads/
مجوز -
## Flask-Threads [![Actions Status](https://github.com/sintezcs/flask-threads/workflows/GitHub%20Build/badge.svg)](https://github.com/sintezcs/flask-threads/actions) A helper library to work with threads within Flask applications. The main problem that you face trying to spin a background thread or running a future in Flask app - is loosing the application context. The most common scenario is to try to access `flask.g` object. Application context is a thread local so you can not access it from another thread and Flask will raise an exception if you would try to. This library provides helper classes that allows you accessing the current application context from another thread. **Warning! Alpha-version, use at your own risk.** ### Installation ```bash $ pip install Flask-Threads ``` ### Examples #### Threads ```python from flask import request from flask import Flask from flaskthreads import AppContextThread app = Flask('my_app') @app.route('/user') def get_user(): g.user_id = request.headers.get('user-id') t = AppContextThread(target=do_some_user_work_in_another_thread) t.start() t.join() return 'ok' def do_some_user_work_in_another_thread(): id = g.user_id print(id) ``` #### Concurrent futures ```python from flask import request from flask import Flask from flaskthreads import ThreadPoolWithAppContextExecutor app = Flask('my_app') @app.route('/user') def get_user(): g.user_id = request.headers.get('user-id') with ThreadPoolWithAppContextExecutor(max_workers=2) as pool: future = pool.submit(do_some_user_work_in_another_thread) future.result() return 'ok' def do_some_user_work_in_another_thread(): id = g.user_id print(id) ```


نحوه نصب


نصب پکیج whl Flask-Threads-0.1.0:

    pip install Flask-Threads-0.1.0.whl


نصب پکیج tar.gz Flask-Threads-0.1.0:

    pip install Flask-Threads-0.1.0.tar.gz