Форум сайта python.su
Всем привет!
Есть проблема, программа поедает ~90 дополнительных КБ каждую минуту
# -*- coding: utf-8 -*- import random from time import sleep from threading import Thread from sys import stdout from grab import Grab timeout = 10 connect_timeout = 10 def c(con, url, post = 0, headers = 0, proxy = 0): global timeout, connect_timeout while True: con.setup(timeout = timeout, connect_timeout = connect_timeout) if post: con.setup(post = post) if headers: con.setup(headers = headers) if proxy: con.setup(proxy_type = "http", proxy = proxy) try: con.go(url) break except Exception as e: if str(e).find("timeout") != -1: stdout.write("#T " + url + " "*5 + "\r") else: stdout.write(str(e)[:50] + "\r") sleep(1 if url.find("likeorgasm") != -1 else 3) def lo(u, con): while True: c(con, "https://api.likeorgasm.ru/method/user.get?" + u) try: con.doc.json break except: print(con.doc.unicode_body()) def _thread(): g = Grab() while True: try: lo("user_token=228", g) stdout.write(g.doc.unicode_body() + " " + str(random.randint(1000,9999)) + "\r") except Exception as e: print(e) for _ in range(100): Thread(target = _thread).start() sleep(.15)
Офлайн