async def consumer_handler(websocket, path):
while True:
message = await websocket.recv()
# делаем что-нибудь с сообщением от клиента
async def producer_handler(websocket, path):
while True:
data = await BSession.GetData()
if data:
await websocket.send(data)
async def handler(websocket, path):
consumer_task = asyncio.ensure_future(consumer_handler(websocket))
producer_task = asyncio.ensure_future(producer_handler(websocket))
done, pending = await asyncio.wait(
[consumer_task, producer_task],
return_when=asyncio.FIRST_COMPLETED,
)
for task in pending:
task.cancel()
loop = asyncio.get_event_loop()
loop.run_until_complete(websockets.serve(handler, 'localhost', 8765))
loop.run_forever()
Надо ли брать потом деньги за доработки?ведь оплата обычно почасовая у программистов
Вообщем как вы все это регулируете со своими клиентами?
create table categories (
id integer primary key,
parent integer references categories,
name varchar(50) not null
);
create table manufacturers (
id integer primary key,
name varchar(30) not null
);
create table goods (
id integer primary key,
category integer references categories,
manufacturer integer references manufacturers,
name varchar(50) not null
);
select
m.name,
count(*) as goods_count
from goods as g
inner join manufacturers as m
on g.manufacturer = m.id
where category = 1
group by m.name;
melkij=> create table events2016m11 (check (dtime >= '2016-11-01'::date AND dtime < '2016-12-01'::date)) inherits(events);
melkij=> insert into events2016m11 values ('2016-11-20');
INSERT 0 1
melkij=> explain (analyze) select * from events where dtime > '2016-12-05';
QUERY PLAN
----------------------------------------------------------------------------------------------------------------
Append (cost=0.00..38.25 rows=754 width=8) (actual time=0.013..0.013 rows=0 loops=1)
-> Seq Scan on events (cost=0.00..0.00 rows=1 width=8) (actual time=0.004..0.004 rows=0 loops=1)
Filter: (dtime > '2016-12-05 00:00:00+03'::timestamp with time zone)
-> Seq Scan on events2016m11 (cost=0.00..38.25 rows=753 width=8) (actual time=0.009..0.009 rows=0 loops=1)
Filter: (dtime > '2016-12-05 00:00:00+03'::timestamp with time zone)
Rows Removed by Filter: 1
Planning time: 0.127 ms
Execution time: 0.032 ms
(8 строк)
melkij=> drop table events2016m11 ;
DROP TABLE
melkij=> create table events2016m11 (check (dtime >= '2016-11-01'::timestamptz AND dtime < '2016-12-01'::timestamptz)) inherits(events);
CREATE TABLE
melkij=> insert into events2016m11 values ('2016-11-20');INSERT 0 1
melkij=> explain (analyze) select * from events where dtime > '2016-12-05'; QUERY PLAN
------------------------------------------------------------------------------------------------------
Append (cost=0.00..0.00 rows=1 width=8) (actual time=0.004..0.004 rows=0 loops=1)
-> Seq Scan on events (cost=0.00..0.00 rows=1 width=8) (actual time=0.004..0.004 rows=0 loops=1)
Filter: (dtime > '2016-12-05 00:00:00+03'::timestamp with time zone)
Planning time: 0.301 ms
Execution time: 0.024 ms
(5 строк)
melkij=> show constraint_exclusion ;
constraint_exclusion
----------------------
partition
(defproject spa-tutorial "0.1.0-SNAPSHOT"
:description "FIXME: write this!"
:url "http://example.com/FIXME"
:dependencies [[org.clojure/clojure "1.8.0"]
[org.clojure/clojurescript "1.9.521"]
[org.clojure/core.async "0.3.442"]
[org.omcljs/om "0.9.0"]
[prismatic/om-tools "0.4.0"]
[http-kit "2.3.0-alpha2"]
[secretary "1.2.3"]]
:plugins [[lein-cljsbuild "1.1.6"]]
:source-paths ["src" "target/classes"]
:clean-targets ["out/spa_tutorial" "out/spa_tutorial.js"]
:cljsbuild {
:builds [{:id "spa-tutorial"
:source-paths ["src"]
:compiler {
:main spa-tutorial.core
:output-to "out/spa_tutorial.js"
:output-dir "out"
:optimizations :none
:verbose true}}]})
from django.apps import apps
from django.core import serializers
# Получаем список всех моделей всех приложений из INSTALLED_APPS
# и фильтруем django'вские
models = [model for model in apps.get_models() if not model.__module__.startswith('django')]
# Сериалзиуем в json полный QuerySet каждой модели
dump = ''
for m in models:
dump += serializers.serialize('json', m._default_manager.all())
На developer.android.com примера нетага, у этих негодяев ваще ничего нет, зачем они только живут?..
with recursive r as (
select
id, parent_id, name
from catalog_category
where id = 8
union
select
cc.id, cc.parent_id, cc.name
from catalog_category as cc
join r
on cc.parent_id = r.id
)
select id, name from r where id <> 8;