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 7651807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T11:35:53+00:00 2026-05-31T11:35:53+00:00

I have a little desktop game written in Python and would like to be

  • 0

I have a little desktop game written in Python and would like to be able to access internal of it while the game is running. I was thinking of doing this by having a web.py running on a separate thread and serving pages. So when I access http://localhost:8080/map it would display map of the current level for debugging purposes.

I got web.py installed and running, but I don’t really know where to go from here. I tried starting web.application in a separate thread, but for some reason I can not share data between threads (I think).

Below is simple example, that I was using testing this idea. I thought that http://localhost:8080/ would return different number every time, but it keeps showing the same one (5). If I print common_value inside of the while loop, it is being incremented, but it starts from 5.

What am I missing here and is the approach anywhere close to sensible? I really would like to avoid using database if possible.

import web
import thread

urls = (
    '/(.*)', 'hello'
)

app = web.application(urls, globals())

common_value = 5

class hello:        
    def GET(self):  
        return str(common_value)

if __name__ == "__main__":
    thread.start_new_thread(app.run, ())    
    while 1:
        common_value = common_value + 1
  • 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-05-31T11:35:55+00:00Added an answer on May 31, 2026 at 11:35 am

    After searching around a bit, I found a solution that works:

    If common_value is defined at a separate module and imported from there, the above code works. So in essence (excuse the naming):

    thingy.py

    common_value = 0
    

    server.py

    import web
    import thread
    import thingy
    
    import sys; sys.path.insert(0, ".")
    
    urls = (
        '/(.*)', 'hello'
    )
    
    app = web.application(urls, globals())
    
    thingy.common_value = 5
    
    class hello:        
        def GET(self):               
            return str(thingy.common_value)
    
    if __name__ == "__main__":
        thread.start_new_thread(app.run, ())    
        while 1:
            thingy.common_value = thingy.common_value + 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a MainMenu in my app and I would like to have little
First, a little background : I have written a little application in python with
I've having a desktop application (a little game) which must be able to post
I have a Django application that I would like to deploy to the desktop.
I have little knowledge of Flash but for a little Flash game I have
I have little doubt about string reading in C. string reading functions like gets,
I've been using python for years, but I have little experience with python web
I have just made my first proper little desktop GUI application that basically wraps
We have a mature Windows desktop application written in C++. The application's GUI sits
I have been a desktop developer for a few years mostly doing object oriented

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.