def handle(self, *args, **options): # sema = threading.BoundedSemaphore(4) c = RC() srv = c.services.client.getServices(clinic=c.search_organization_id()) self.stdout.write("!!!!!!!") self.cnt = len(srv) def ip(self, c, r): # sema.acquire() try: data = helpers.serialize_object( c.services.client.getService(r["id"])) inactive = False if data["toDate"]: inactive = datetime.strptime( data["toDate"].strftime('%Y%m%d'), "%Y%m%d") < datetime.now() RMISServiceInactive.checkInactive(serviceId=r["id"], enabled=inactive) finally: self.n += 1 self.nn += 1 if self.n % 10 == 0 or self.n == self.cnt: self.stdout.write("{}/{}".format(self.n, self.cnt)) if self.n % 100 == 0 or self.n == self.cnt: sec = time.time() - self.start_time self.start_time = time.time() self.stdout.write("--- %s op/s ---" % (int(self.nn / sec))) self.nn = 0 # sema.release() self.start_time = time.time() threads = [] for r in srv: ip(self, c, r) # thread = threading.Thread(target=ip, args= # threads.append(thread) # thread.start() [t.join() for t in threads]
def rmis_check(request): c = Client() return HttpResponse(c.search_organization_id(check=True) + " " + c.search_dep_id(check=True), content_type="text/plain")