This file contains hidden or 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 "dart:math"; | |
enum Thing { one, two, three } | |
// The compiler complains that this function could return null, even though the switch is exhaustive. | |
// It seems to be due to the parentheses around each case clause. | |
String randomThing() { | |
final thing = Thing.values[Random().nextInt(Thing.values.length)]; | |
switch (thing) { | |
case (Thing.one): |
This file contains hidden or 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 collections import namedtuple | |
from functools import partial | |
Inning = namedtuple("Inning", ["half", "of"]) | |
top = partial(Inning, half="top") | |
bottom = partial(Inning, half="bottom") | |
inning = bottom(of=9) |
This file contains hidden or 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 flask import Flask | |
app = Flask(__name__) | |
@app.route("/wins/<int:number>") | |
def wins(number): | |
if number > 162: | |
return "Too many wins!" | |
return ("W" * number) + "indians" |
This file contains hidden or 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 diesel | |
class MyClient(diesel.Client): | |
def __init__(self, *args, **kw): | |
super(MyClient, self).__init__(*args, **kw) | |
# fork a background Loop to handle async messages | |
diesel.fork_child(self._dispatch_messages) | |
@diesel.call | |
def send_request(self, req): |
This file contains hidden or 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 socket | |
import diesel.core | |
from diesel import Service | |
from diesel.core import Connection, Loop | |
from diesel.util.queue import Queue | |
def forward(service): |
This file contains hidden or 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/diesel/__init__.py b/diesel/__init__.py | |
index 93335ea..b085667 100644 | |
--- a/diesel/__init__.py | |
+++ b/diesel/__init__.py | |
@@ -1,7 +1,7 @@ | |
# vim:ts=4:sw=4:expandtab | |
from logmod import log, levels as loglevels, set_log_level | |
import events | |
-from core import sleep, Loop, wait, fire, thread, until, Connection, UDPSocket, ConnectionClosed, ClientConnectionClosed, signal | |
+from core import sleep, Loop, wait, fire, thread, until, Connection, UDPSocket, ConnectionClosed, ClientConnectionClosed |
This file contains hidden or 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
(env) christian@dowski-dev:~/py332/src/diesel$ dnosetests tests/unit/ tests/integration/ | |
................................................... | |
---------------------------------------------------------------------- | |
Ran 51 tests in 8.300s | |
OK |
This file contains hidden or 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/diesel/core.py b/diesel/core.py | |
index 268b071..249895e 100644 | |
--- a/diesel/core.py | |
+++ b/diesel/core.py | |
@@ -317,6 +317,7 @@ class Loop(object): | |
ClientConnectionTimeout("connection timeout (%s:%s)" % (host, port)) | |
)) | |
+ status = {'dead':False} | |
def connect_callback(): |
This file contains hidden or 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
$ python br-tryexcept.py | |
[2013/06/03 14:18:19] {diesel} WARNING:Starting diesel <hand-rolled select.epoll> | |
[2013/06/03 14:18:19] {diesel} ERROR:internal error: expected empty read on disconnected socket | |
error connecting | |
[2013/06/03 14:18:20] {diesel} ERROR:internal error: expected empty read on disconnected socket | |
error connecting | |
[2013/06/03 14:18:21] {diesel} ERROR:internal error: expected empty read on disconnected socket | |
error connecting | |
[2013/06/03 14:18:22] {diesel} ERROR:internal error: expected empty read on disconnected socket | |
error connecting |
This file contains hidden or 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 diesel | |
from diesel.protocols.redis import RedisClient | |
def main(): | |
try: | |
c = RedisClient('localhost', int(sys.argv[1])) | |
except diesel.ClientConnectionError: |
NewerOlder