Skip to content

Instantly share code, notes, and snippets.

@limafm
limafm / multiprocessing Pool is stuck
Last active August 28, 2020 20:35
multiprocessing Issues
# artigo onde o autor explica o motivo de travamento
https://pythonspeed.com/articles/python-multiprocessing/
# multiprocessing.set_start_method
https://docs.python.org/3/library/multiprocessing.html#multiprocessing.set_start_method
# AttributeError: Can't pickle local object
https://stackoverflow.com/questions/52265120/python-multiprocessing-pool-map-attributeerror-cant-pickle-local-object
# AttributeError: Can\'t pickle local object \'_objective_function_wrapper.<locals>.inner #2189
@limafm
limafm / pool_x_2
Created August 9, 2018 19:28
Python - pool inside of a pool?
# reference:
# https://stackoverflow.com/questions/6974695/python-process-pool-non-daemonic/8963618#8963618
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import multiprocessing
# We must import this explicitly, it is not imported by the top-level
# multiprocessing module.
import multiprocessing.pool
@limafm
limafm / remove-from-list
Created July 19, 2018 19:27
Remove all the elements that occur in one list from another
l1 = [1,2,6,8]
l2 = [2,3,5,8]
l3 = [x for x in l1 if x not in l2] # l3 will contain [1, 6]
@limafm
limafm / multi.py
Created July 5, 2018 15:40
Python multiprocessing
import multiprocessing
import time
from random import randint
PROCESSES = 5
WORKER_CALLS = 7
def worker(num):
"""worker function"""
print 'Starting worker', num
@limafm
limafm / docker-with-localhost
Created May 2, 2018 18:29
Docker run with localhost access
docker run --net=host <docker-image>
@limafm
limafm / Dockerfile-with-node-gyp
Created March 5, 2018 20:01
node-gyp within Docker
FROM node:8.9.4-alpine
RUN apk --no-cache add python build-base
RUN mkdir -p /app
WORKDIR /app
@limafm
limafm / Run multiple commands in docker-compose
Last active February 23, 2018 19:01
Run multiple commands in docker-compose
PS.: Your image need to have support for bash
command: bash -c "python manage.py migrate && python manage.py runserver 0.0.0.0:8000"
command: >
bash -c "python manage.py migrate
&& python manage.py runserver 0.0.0.0:8000"
Credits: https://stackoverflow.com/questions/30063907/using-docker-compose-how-to-execute-multiple-commands/30064175
@limafm
limafm / how to configure ssl on development server
Created July 28, 2017 14:41 — forked from andrewslince/how to configure ssl on development server
Script to configurate a fake ssl virtual host, using Apache Server, on Linux.
#!/bin/bash
##################################################################################################
## ##
## Credits: ##
## - http://www.phpit.com.br/artigos/configurando-ssl-servidor-de-desenvolvimento-apache.phpit ##
## - http://wime.com.br/2013/06/28/como-criar-certificado-ssl-no-apache-para-ubuntu-12-04/ ##
## ##
##################################################################################################
UNDO A LAST LOCAL COMMIT
# use --soft if you want to keep your changes
git reset --soft HEAD^
# use --hard if you don't care about keeping the changes you made
git reset --hard HEAD^
---------------------------------
UNDO A LAST PUBLIC COMMIT