Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
loop running indefinitely
#3
I don't see it running forever, but the logic looks odd. I think what you are trying to do is process years up to 1985 using the USA API and from 1985 onward using the Australia API. This is not what your code does. Because the Australia API loop is embedded inside the USA API loop, your code will only call the Australia API if the start year is prior to 1985, and it is called repeatedly, once for each year prior to 1985. I would write the code like this:

for year in range(start_year, end_year+1):  # do you want to include end_year?
    if year < 1985:
        # USA API
    else:
        # Australia API
Reply


Messages In This Thread
loop running indefinitely - by shantanu97 - Jun-14-2021, 12:10 PM
RE: loop running indefinitely - by snippsat - Jun-14-2021, 12:55 PM
RE: loop running indefinitely - by deanhystad - Jun-14-2021, 02:06 PM
RE: loop running indefinitely - by Gribouillis - Jun-14-2021, 03:38 PM
RE: loop running indefinitely - by deanhystad - Jun-14-2021, 04:52 PM
RE: loop running indefinitely - by Underscore - Sep-29-2021, 05:58 PM
RE: loop running indefinitely - by deanhystad - Sep-29-2021, 08:03 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  help RuntimeError: no running event loop marpaslight 5 3,811 Oct-18-2022, 10:04 PM
Last Post: marpaslight
  bleak library RuntimeError: This event loop is already running alice93 3 4,146 Sep-30-2021, 08:06 AM
Last Post: alice93
  Running A Loop Until You See A Particular Result knight2000 6 31,760 Sep-04-2021, 08:55 AM
Last Post: knight2000
  Running loop at specific frequency mdsousa 3 6,015 Apr-21-2021, 11:22 AM
Last Post: jefsummers
  RuntimeError: This event loop is already running newbie2019 2 6,992 Sep-30-2020, 06:59 PM
Last Post: forest44
  Running function from parent module which has a loop in it. ta2909i 1 2,715 Nov-18-2019, 07:04 PM
Last Post: Gribouillis
  How to add coroutine to a running event loop? AlekseyPython 1 8,203 Mar-21-2019, 06:04 PM
Last Post: nilamo
  action on MQTT while long loop is running runboy 4 6,129 Oct-05-2018, 11:57 PM
Last Post: runboy
  Outer loop not running ted_gress 2 3,355 Aug-25-2018, 07:56 AM
Last Post: volcano63
  Running Class methods in a loop and updating variables. ujjwalrathod007 3 6,423 Oct-05-2016, 07:11 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020