Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9146801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:49:59+00:00 2026-06-17T10:49:59+00:00

I have a Bottle application that uses subprocesses to do most of the work

  • 0

I have a Bottle application that uses subprocesses to do most of the work for requests. For routes that return a single response, I do something like what’s below.

@route('/index')
def index():
    worker = getWorker()
    return worker.doStuff()

One of my routes needs to be a data stream. I can’t figure out a smart way to have the worker return a response stream. The example below is similar to what I want to do, only without a worker.

@route('/stream')
def stream():
    yield 'START'
    sleep(3)
    yield 'MIDDLE'
    sleep(5)
    yield 'END'

I’d like to be able to do something like below. Since I can’t yield/return a generator this isn’t possible this way.

@route('/stream')
def stream():
    worker = getWorker()
    yield worker.doStuff()
class worker:
    # Remember, this is run in a subprocess in real life.
    def doStuff():
        yield 'START'
        sleep(3)
        yield 'MIDDLE'
        sleep(5)
        yield 'END'

This is for a large project and I don’t have much flexibility in the way that I do things. I know sometimes the easiest answer is “your design is wrong.” In this case though, I have some constraints that are beyond my control (the route has to be a data stream and the work has to be done by a subprocess).

EDIT
I also can’t have doStuff() block. I’d like to be able to create something like a gevent queue that I return and have the worker process. The problem now is that it doesn’t seem like I can use gevent.queue and Process together.

@route('/stream')
def index():
    body = gevent.queue.Queue()
    worker = multiprocessing.Process(target=do_stuff, args=body)
    worker.start()
    return body()

def do_stuff(body):
    while True:
        gevent.sleep(5)
        body.put("data")
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T10:50:00+00:00Added an answer on June 17, 2026 at 10:50 am

    After a lot of research and experimenting, I’ve determined that a gevent queue can’t be used with Python multiprocessing in this way. Instead of doing things this way, something like redis can be used to allow the processes and gevent greenlets communicate.

    @route('/stream')
    def index():
        worker = multiprocessing.Process(target=do_stuff)
        worker.start()
        yield redis_server.lpop()
    
    def do_stuff(body):
        while True:
            gevent.sleep(5)
            redis_server.lpush("data")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Python application in the bottle web-server that accesses a C shared-object
I have a relatively simple program that currently uses 1 thread (main). The application
I have a web application (webservices) that combine Bottle web framework and Jython ...
I have a bottle.py application which has a number of routes already built. I
So i supose that i have a server application written in python import bottle
I have pin pointed a bottle neck in my application, it seems to me
I have a silverlight 3 application, that fetches some simple data from a ms-sql-server
I have a rest server running (python bottle) on the same host that is
I have a simple bottle.py app that let's me upload files. Now since those
In My Application i have View like this image: Now, I want to make

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.