-
This is a numbered list.
-
I'm going to include a fenced code block as part of this bullet:
Code More Code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
This demonstrates a task scheduling loop where tasks can send back other tasks to the queue. | |
Program input: a nested list of items that can either be integers, whose processing is simulated by waiting | |
a proportional amount of time, or another list, in which case after waiting a time proportional to its length, | |
sub-items are rescheduled for processing. | |
Solution is inspired by goroutines, channels and waitgroups. | |
Asyncio's Queue can serve both as channel and waitgroup, thanks to Queue.join() that blocks until the queue is empty. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
from typing import Awaitable, Callable, Coroutine, Iterator | |
from asyncio_pool import AioPool | |
import pytest as pytest | |
from more_itertools import peekable | |
""" | |
Different approaches to "How to limit concurrency with Python asyncio?" | |
https://stackoverflow.com/questions/48483348/how-to-limit-concurrency-with-python-asyncio/48484593#48484593 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#http://geekgirl.io/concurrent-http-requests-with-python3-and-asyncio/ | |
Concurrent HTTP Requests with Python3 and asyncio | |
My friend who is a data scientist had wipped up a script that made lots (over 27K) of queries to the Google Places API. The problem was that it was synchronous and thus took over 2.5hours to complete. | |
Given that I'm currently attending Hacker School and get to spend all day working on any coding problems that interests me, I decided to go about trying to optimise it. | |
I'm new to Python so had to do a bit of groundwork first to determine which course of action was best. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
from django.conf import settings | |
from django.contrib.auth import logout | |
from django.contrib.auth.models import User | |
from django.contrib.sessions.models import Session | |
from django.core.management.base import NoArgsCommand | |
from django.http import HttpRequest | |
from django.utils.importlib import import_module |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- author: Paul Kulchenko | |
--------------------------------------------------------- | |
local funccall = "([A-Za-z_][A-Za-z0-9_]*)%s*" | |
return { | |
exts = {"js", "json"}, | |
lexer = wxstc.wxSTC_LEX_ESCRIPT, | |
apitype = "js", | |
linecomment = "//", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.core import urlresolvers | |
resolver = urlresolvers.get_resolver(None) | |
url_re_list = ['^/' + url[1] for url in resolver.reverse_dict.itervalues()] |