Skip to content

Instantly share code, notes, and snippets.

@J3ronimo
J3ronimo / hx_crawler.py
Created November 30, 2020 15:04
hornoxe picdump crawler
import os
import time
import argparse
import requests
import threading
import queue
class ImgDownloader(threading.Thread):
def __init__(self, folder, img_url_fmt, start, interval, print_queue):
@J3ronimo
J3ronimo / service.py
Last active August 16, 2019 13:35
Windows service wrapper for Python scripts, using pywin32
"""
Usage:
python service.py install
Installs this script as a Windows service. Needs admin rights.
python service.py remove
Remove service. Needs admin rights.
"""
@J3ronimo
J3ronimo / with_lock.py
Last active October 5, 2018 08:32
Simple Lock decorator for bound methods
import threading
import functools
def with_lock(func):
""" Synchronization decorator applicable to bound methods, which
creates a threading.Lock for the decorated function, which is then acquired
on every call to the method.
Locks created will be stored in the dict self._func_locks. """
@functools.wraps(func)
def wrapped(self, *args, **kwargs):
@J3ronimo
J3ronimo / interruptable_thread.py
Last active April 20, 2018 10:10
Interruptable threading.Thread, based on https://gist.github.com/liuw/2407154
import threading
import ctypes
import time
class InterruptableThread(threading.Thread):
""" Interruptable threading.Thread, based on:
https://gist.github.com/liuw/2407154
Calling this thread's interrupt() method from the main thread will raise
an Exception inside run(), which will stop the execution.