[ 
https://issues.apache.org/jira/browse/THRIFT-1848?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Piotr Nowojski updated THRIFT-1848:
-----------------------------------

    Description: 
As far as I know, there is no support in python for anything else, then 
blocking communication/non-blocking/twisted. Non-blocking is not 
asynchronous and we definitely don't want to use twisted. I'm really 
interested in adding support for onCompleted/onError callbacks model. 
After small research, I've found couple of discussions/complains about 
missing such functionality.

The main idea is to allow users (for example my project in my company...) to 
create single threaded thrift servers, with one thread processing all thrift 
requests AND user created events. Support for custom events (and events loop) 
is done, by adding support for "step()" method in WorkerAsync(), which is being 
called at least once a given timeout. Example code is in the tutorial py.async. 

I have added "sleep(duration)" command to the py.async PythonServer which is 
being invoked on PythonClient, which sleeps for given number of seconds (1.5 in 
PythonClient). 

console1: ./PythonServer.py

console2: for i in {1..100}; do ./PythonClient.py & done

Second console will complete within ~2 seconds with only one thread on the 
server. On TSimpleServer, TNonblockingServer or TThreadPoolServer with about 10 
threads, it would take much more time to complete.

  was:
As far as I know, there is no support in python for anything else, then 
blocking communication/non-blocking/twisted. Non-blocking is not 
asynchronous and we definitely don't want to use twisted. I'm really 
interested in adding support for onCompleted/onError callbacks model. 
After small research, I've found couple of discussions/complains about 
missing such functionality.

The main idea is to allow users (for example my project in my company...) to 
create single threaded thrift servers, with one thread processing all thrift 
requests AND user created events. Support for custom events (and events loop) 
is done, by adding support for "step()" method in WorkerAsync(), which is being 
called at least once a given timeout. Example code is in the tutorial py.async.

console1: ./PythonServer.py

console2: for i in {1..100}; do ./PythonClient.py & done

Second console will complete within ~2 seconds with only one thread on the 
server.

    
> Python asynchronous server
> --------------------------
>
>                 Key: THRIFT-1848
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1848
>             Project: Thrift
>          Issue Type: New Feature
>          Components: Python - Compiler, Python - Library
>    Affects Versions: 1.0, 1.1, 1.2
>            Reporter: Piotr Nowojski
>         Attachments: thrift-1848-python-async-server.patch
>
>
> As far as I know, there is no support in python for anything else, then 
> blocking communication/non-blocking/twisted. Non-blocking is not 
> asynchronous and we definitely don't want to use twisted. I'm really 
> interested in adding support for onCompleted/onError callbacks model. 
> After small research, I've found couple of discussions/complains about 
> missing such functionality.
> The main idea is to allow users (for example my project in my company...) to 
> create single threaded thrift servers, with one thread processing all thrift 
> requests AND user created events. Support for custom events (and events loop) 
> is done, by adding support for "step()" method in WorkerAsync(), which is 
> being 
> called at least once a given timeout. Example code is in the tutorial 
> py.async. 
> I have added "sleep(duration)" command to the py.async PythonServer which is 
> being invoked on PythonClient, which sleeps for given number of seconds (1.5 
> in PythonClient). 
> console1: ./PythonServer.py
> console2: for i in {1..100}; do ./PythonClient.py & done
> Second console will complete within ~2 seconds with only one thread on the 
> server. On TSimpleServer, TNonblockingServer or TThreadPoolServer with about 
> 10 threads, it would take much more time to complete.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to