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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:51:36+00:00 2026-05-13T09:51:36+00:00

I’m having a problem reading and processing data from my server. I’ve spent hours

  • 0

I’m having a problem reading and processing data from my server. I’ve spent hours debugging this and it seems as though the problem has nothing to do with the server but is really just an issue with one of my for loops. Its difficult to explain this without actually seeing the data from the server, but I’ll do my best to explain this.

Basically I have a server that when I send a command, it returns to me 5 different XML strings sequentially. My program parses this data into Python dictionaries and stores them in different class attributes. As TCP is a stream, I usually don’t receive each string separately. What usually happens is I’ll receive the first string, then the next 4 strings in groups of 2. So theres normally 3 different iterations of the for loop. However, the last string fails to get processed and stored in an attribute. Here’s the logic containing the for loop in question:

 def xmlParser(self, newData):
     print newData
     for string in newData:
         if 'a' in string:
             print 'string1 being processed'
             xmlToDictionary(string, 'string1')
         elif 'b' in string:
             print 'string2 being processed'
             xmlToDictionary(string, 'string2')
         elif 'c' in string:
             print 'string3 being processed'
             xmlToDictionary(string, 'string3')
         elif 'd' in string:
             print 'string4 being processed'
             xmlToDictionary(string, 'string4')
         elif 'e' in string:
             print 'string5 being processed'
             xmlToDictionary(string, 'string5')

The print statements are solely for debugging purposes. My first reaction to the last string not being processed was that it simply wasn’t being received. However, by printing newData I can verify that all the strings are received and sent to this function. The newData is a list containing the strings to be processed. For the 3 different iterations, newData looks like this

newData = ['string1']
newData = ['string2', 'string3']
newData = ['string4', 'string5']

Its ‘string5’ that isn’t processed, and I don’t believe its because of an exception being raised in xmlToDictionary() because the string ‘string5 being processed’ isn’t printed. And if I include an else statement in the function, that isn’t executed either. Its as if the for loop just refuses to perform a second iteration on the last group of data. To test things further, I modified the server script to send ‘string5’ before ‘string4’ and, to my surprise, completely fixed the issue and caused ‘string5’ to be processed and stored as a dictionary. In this situation, newData looked like this

newData = ['string1']
newData = ['string2', 'string3', 'string5']
newData = ['string4']

I also tried modifying the server script to stop sending ‘string4’ altogether. This also was successful in allowing ‘string5’ to be processed. The for loop only performed two iterations and newData looked like this

newData = ['string1']
newData = ['string2', 'string3', 'string5']

I tried to put all this together into determining what the problem is, but I’m totally confused. I’ve never encountered something like this before. If I can’t come up with a solution, I’ll either leave the script to send ‘string5’ before ‘string4’ or I may simply combine all the strings on the server and have it sent as one big string. Regardless, I would still like to determine what is going on here since it may indicate a deeper problem with my program.

  • 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-13T09:51:36+00:00Added an answer on May 13, 2026 at 9:51 am

    Well, this is a stumper. Especially since you have not posted the real code, but your own concept of how the code should be working. Since there is nothing wrong with this concept, there is nothing wrong with your example.

    Still, I copied out your code, and then tried to perturb it to get your results. I think the most likely culprit is that you have some undesirable side effect occurring in your code that processes string4’s. Your description sounds very much like what happens when a list is modified while it is being iterated over. Here’s one example that would cause the exact behavior you describe:

    elif 'd' in string: 
        print 'string4 being processed' 
        # undesirable side effect occurs here
        newData.remove(string)
        xmlToDictionary(string, 'string4') 
    

    Try sending a sequence like [string4, string1] and see if string1 gets through. If not, there is a strong chance that some kind of side-effect is coming from this chunk of code.

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

Sidebar

Ask A Question

Stats

  • Questions 403k
  • Answers 403k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer A VerifyError means the bytecode is invalid, which points to… May 15, 2026 at 5:06 am
  • Editorial Team
    Editorial Team added an answer You can use the :methods argument to to_xml for this… May 15, 2026 at 5:06 am
  • Editorial Team
    Editorial Team added an answer No. As stated in the book, an URL of the… May 15, 2026 at 5:06 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.