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

  • Home
  • SEARCH
  • 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 3244758
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:35:22+00:00 2026-05-17T18:35:22+00:00

I’m currently in the process of writing a client server app as an exercise

  • 0

I’m currently in the process of writing a client server app as an exercise and I’ve gotten pretty much everything to work so far, but there is a mental hurdle that I haven’t been able to successfully google myself over.

In the server application am I correct in my thinking that threading the packet handler and database handler to work from a stack is the right thing to do? The idea is that one thread loops listening for packets and adds the data to a stack and then the other thread pops the data off the bottom of the stack and does some checks against an SQL db.

In this particular case, it’s more important for the packet handler to keep working. I guess my question is, is this an appropriate use of threads and where am I going to run into problems that require thread locking, for example, should I lock the db handler when the packet thread adds to the stack to avoid an issue with trying to write and read say, the only value in the stack, etc.

Thanks everyone!

Here is a snippet of the code, mind you it’s in progress so don’t judge, also my first attempt at python (which I am enjoying more than perl or php at the moment!).

class socketListen(threading.Thread):
    def run(self):
        while True:
            datagram = s.recv('1024')
            if not datagram:
                break
            packetArray = datagram.split(',')
            if packetArray[0] = '31337':
                listHandle.put(packetArray)
        s.close()

class stackOperations(threading.Thread):
    def run(self):
        while True:
            #pull the last item off the stack and run ops on it
            #listHandle.getLast is the last item on the queue
    def 

class listHandle():
    def put(shiftData):
        if not mainStack:
            mainStack = []
        mainStack.insert(0,shiftData)
    def getLast:
        return mainStack.pop()
  • 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-17T18:35:22+00:00Added an answer on May 17, 2026 at 6:35 pm

    This is what queues are for. Replace stack with queue and no, you won’t have to use any other synchronization methods. Incidentally, multiprocessing is better than threading, since it can take advantage of multicore/hyperthreaded processors. The interfaces are pretty similar, so it’s worth looking into switching.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am currently running into a problem where an element is coming back from
I want use html5's new tag to play a wav file (currently only supported
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I need to clean up various Word 'smart' characters in user input, including but
I have a JSP page retrieving data and when single or double quotes are
Does anyone know how can I replace this 2 symbol below from the string

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.