global
statement detected PYL-W0603 86 workers = file_download.get("workers", 4)
87 buffer_ = file_download.get("buffer", 4096)
88 avg_st_speed: float = 0
89 global EXIT_FLAG, MAX_TIME, TOTAL_RECEIVED, MAX_FILE_SIZE 90
91 dlrm = DownloadRuleMatch(file_download)
92 res = dlrm.get_url(await ip_loc(port))
22
23
24def speed_test_thread(link, buffer):
25 global TOTAL_RECEIVED, MAX_TIME 26 logger.debug(f"Thread {threading.current_thread().ident} started.")
27 link = link.replace("https://", "").replace("http://", "")
28 host = link[: link.find("/")]
It is recommended not to use global
statement unless it is really necessary. Global variables are dangerous because they can be simultaneously accessed from multiple sections of a program. This frequently results in bugs. This also make code difficult to read, because they force you to search through multiple functions or even modules just to understand all the different locations where the global variable is used and modified. Read more about why it should be avoided here.