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 aiohttp.server import ServerHttpProtocol | |
import unittest | |
import threading | |
from urllib.request import urlopen, URLError | |
class Test(unittest.TestCase): | |
def setUp(self): | |
import logging |
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
// Read this first: http://code.activestate.com/recipes/393090/ | |
function sum(ar) { | |
var c = ar.length; | |
var s = 0; | |
for (var i = 0; i < c; i++) { | |
s += ar[i]; | |
} | |
return s; | |
} |
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 os | |
import sys | |
import token | |
import tokenize | |
if __name__ == '__main__': | |
if len(sys.argv) < 2: | |
print('pass directory to search in as an arg') | |
sys.exit(1) |
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 sys | |
import time | |
# import sys | |
# sys.set_generator_wrapper(lambda x: x) | |
def binary(n): | |
if n <= 0: | |
return 1 |
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
class CM: | |
def __enter__(self): | |
global CNT1 | |
CNT1 +=1 | |
def __exit__(self, et, e, tv): | |
global CNT2 | |
CNT2 += 1 | |
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
diff --git a/Grammar/Grammar b/Grammar/Grammar | |
index 94898d3..9c74096 100644 | |
--- a/Grammar/Grammar | |
+++ b/Grammar/Grammar | |
@@ -21,8 +21,11 @@ eval_input: testlist NEWLINE* ENDMARKER | |
decorator: '@' dotted_name [ '(' [arglist] ')' ] NEWLINE | |
decorators: decorator+ | |
-decorated: decorators (classdef | funcdef) | |
-funcdef: 'def' NAME parameters ['->' test] ':' suite |
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
diff --git a/Lib/test/test_coroutines.py b/Lib/test/test_coroutines.py | |
index aa2a5e8..6a6f868 100644 | |
--- a/Lib/test/test_coroutines.py | |
+++ b/Lib/test/test_coroutines.py | |
@@ -497,17 +497,133 @@ class CoroutineTest(unittest.TestCase): | |
return self | |
def __aexit__(self, *e): | |
+ return 444 | |
+ |
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 | |
async def worker(): | |
fut = asyncio.Future() | |
def setval(): | |
print('setval') | |
fut.set_result(123) | |
print('setup') |
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 | |
async def http_get(domain): | |
reader, writer = await asyncio.open_connection(domain, 80) | |
writer.write(b'\r\n'.join([ | |
b'GET / HTTP/1.1', | |
b'Host: %b' % domain.encode('latin-1'), | |
b'Connection: close', | |
b'', b'' |
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
class _RedisPool(aioredis.RedisPool): | |
@asyncio.coroutine | |
def acquire(self): | |
# XXX | |
with (yield from self._cond): | |
while True: | |
yield from self._fill_free(override_min=True) | |
if self.freesize: | |
conn = self._pool.popleft() | |
if conn.closed: |