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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:07:08+00:00 2026-06-12T09:07:08+00:00

How to solve this error? i want to pass the values from get_robotxya() and

  • 0

How to solve this error? i want to pass the values from get_robotxya() and get_ballxya()
and use it in a loop but it seems that it will crash after awhile how do i fix this? i want to get the values whithout it crashing out of the while loop

import socket
import os,sys
import time
from threading import Thread

HOST = '59.191.193.59'
PORT = 5555

COORDINATES = []

def connect():   
    globals()['client_socket'] = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    client_socket.connect((HOST,PORT))

def update_coordinates():
    connect()
    screen_width = 0
    screen_height = 0
    while True:
        try:
            client_socket.send("loc\n")
            data = client_socket.recv(8192)
        except:
            connect();
            continue;

        globals()['COORDINATES'] = data.split()

        if(not(COORDINATES[-1] == "eom" and COORDINATES[0] == "start")):
            continue

        if (screen_width != int(COORDINATES[2])):
            screen_width = int(COORDINATES[2])
            screen_height = int(COORDINATES[3])
            return

def get_ballxy():
    update_coordinates()
    ballx = int(COORDINATES[8])
    bally = int(COORDINATES[9])

    return ballx,bally

def get_robotxya():
    update_coordinates()
    robotx = int(COORDINATES[12])
    roboty = int(COORDINATES[13])
    angle = int(COORDINATES[14])
    return robotx,roboty,angle

def print_ballxy(bx,by):

    print bx
    print by

def print_robotxya(rx,ry,a):

    print rx
    print ry
    print a

def activate():

    bx,by = get_ballxy()
    rx,ry,a = get_robotxya()
    print_ballxy(bx,by)
    print_robotxya(rx,ry,a)


Thread(target=update_coordinates).start()
while True:
    activate()

this is the error i get:
enter image description here

  • 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-12T09:07:08+00:00Added an answer on June 12, 2026 at 9:07 am

    I think you’ll find that, because you’re continuously creating new connections without closing them down, you’ll eventually run out of resources.

    That may be a local limitation or it may be the server end getting fed up with too many connections from a single IP.

    Regardless, either create one connection and use it over and over, or shut down connections when you’re done with them.


    One possible way of doing this is to connect() within the main code before calling activate():

    connect()
    update_coordinates()
    while True:
        activate()
    

    Then remove the initial connect() from the start of the update_coordinates() function since that’s the bit that does a new connection every time you try to update the coordinates.

    If the session goes down for some reason, the except bit will re-create it and try again.

    That should hopefully alleviate your resource problem quite a bit.

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

Sidebar

Related Questions

My question is not about how to solve this error(I already solved it) but
I'm quite new to PHP so I don't know how to solve this error.
How to solve this HTML 5 validation error related to Facebook like button? Here
I am overloading the assignment operator, and am getting this error. Cannot solve it.
This code shows syntax error in the parameter declaration.. Pls help me to solve
This query gives me syntax error in when-between line. how can i solve them?
I'm trying to solve a segmentation fault. This message appears in my apache-error.log: [notice]
This function works fine if I disable errors. But I have to solve them.
I've been trying to solve this problem for a couple of hours but I
Here's the problem I'm trying to solve. I want to pass a date, then

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.