Skip to content

Instantly share code, notes, and snippets.

View emr-arvig's full-sized avatar

Evan Roggenkamp emr-arvig

  • Arvig
View GitHub Profile
@emr-arvig
emr-arvig / asyncio_executors_threads_procs.py
Created June 21, 2021 16:02 — forked from jmbjorndalen/asyncio_executors_threads_procs.py
Combining Python 3 asyncio coroutines with thread pool and process pool executors
#!/usr/bin/env python3
# Combining coroutines running in an asyncio event loop with
# blocking tasks in thread pool and process pool executors.
#
# Based on https://pymotw.com/3/asyncio/executors.html, but this version runs both
# threads and processes at the same time and interleaves them with asyncio coroutines.
#
# All appears to be working.
#
@emr-arvig
emr-arvig / quick_logging.py
Last active March 7, 2022 17:32
logging basic config - quick and easy to get up and running
import os
import logging
import logging.handlers
stream_handler = logging.StreamHandler()
stream_handler.setLevel(logging.INFO)
file_handler = logging.FileHandler(f"{os.getcwd()}/my_log.log")
logging.basicConfig(
@emr-arvig
emr-arvig / dcim_choices_depreciated.json
Created August 20, 2020 17:20
Netbox Importer Choices Route Depreciation Hack
{
"cable:length_unit": [
{
"value": "m",
"label": "Meters"
},
{
"value": "cm",
"label": "Centimeters"
},
@emr-arvig
emr-arvig / .gitignore
Created October 30, 2019 20:14
my .gitignore
credentials.py
__pycache__/
*.py[cod]
*venv/
*.venv/
*.crt
*.key
*.env
*.log
*.retry
@emr-arvig
emr-arvig / mp_callback_test.py
Last active September 23, 2019 02:18
Multiprocessing callback example
from multiprocessing import Pool
RESULTS = []
CALLBACK_DATA = []
def mycallback(x):
print('mycallback is called with {}'.format(x))
CALLBACK_DATA.append(x)
def multiply_by_two(x):