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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T15:07:44+00:00 2026-06-16T15:07:44+00:00

I want to do a simple thing: just bind two ports to wait for

  • 0

I want to do a simple thing: just bind two ports to wait for incoming connections and continous with the application code. This is the code.

import socket
import threading
import Queue

q = Queue.Queue()
q2 = Queue.Queue()

def escucha_9003():

    s = socket.socket()
    s.bind(("localhost",9023))
    s.listen(10) 
    sc, address = s.accept()
    q.put(sc)



def escucha_9004():

    s2 = socket.socket()
    s2.bind(("localhost",9024))
    s2.listen(10) 
    sc2, address2 = s2.accept()
    q.put(sc2)

hilo = threading.Thread(target=escucha_9003).start()
sc2=q.get()
hilo2 = threading.Thread(target=escucha_9004).start()
sc=q2.get()

print "i never arrive here"

I need to get some parameters that are returned in each function. I use Queue library to do it.
But the problem is that i want to keep working with the code and I never arrive to the line: print “i never arrive here”. At least it is never printed.

How need I do it to continue developing after launch those two threads and work with the incoming connections.

Thank you very much

  • 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-16T15:07:46+00:00Added an answer on June 16, 2026 at 3:07 pm

    Both .get() calls are blocking calls. Also, the .accept() calls in your threads are blocking. Technically you should never even get past the two .accept() calls if no connections are coming in from clients. Because the main thread is waiting on get() calls from the queues, but the queues never put anything because the threads are waiting on accepting a future connection.

    What you would need to do is handle your queues from within threads instead of inside of the main thread. Otherwise, you will need to use .get(timeout=someSeconds) inside of an event loop where you keep checking for more stuff in your queues for a certain amount of time, and then move on to do more continuous processing.

    You may want to explain exactly what you are trying to achieve, and then restructure these threads to handle a bit more of their own work before blocking the main thread to receive data.

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

Sidebar

Related Questions

It's really simple, I just want one screen. Wow, that [shiny thing] must have
I just want to know one simple thing in Java. Let's consider the following
Just got a quick question, this is a simple thing to do via PHP
This might be a very simple thing that I'm overlooking, but I just can't
I'm stunned by a simple thing that I want to accomplish but does not
A very simple thing, and I can't get it to work. I want to
I want to implement this simple animation in knockout: function scroll(back) { var scrollContainer
I'll try to make this as simple a posible. I just started working with
This seems like a really simple thing to do but I cant't seem to
This query is working correctly, it generates a column called total_each I just want

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.