File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -103,6 +103,7 @@ def __init__(
103
103
* ,
104
104
client : clickhouse_driver .Client ,
105
105
insert_interval : int = 1 ,
106
+ insert_every : int = 500 ,
106
107
draw_idx : int = 0 ,
107
108
):
108
109
self ._draw_idx = draw_idx
@@ -113,6 +114,7 @@ def __init__(
113
114
self ._insert_queue = []
114
115
self ._last_insert = time .time ()
115
116
self ._insert_interval = insert_interval
117
+ self ._insert_every = insert_every
116
118
super ().__init__ (cmeta , rmeta )
117
119
118
120
def append (
@@ -126,7 +128,10 @@ def append(
126
128
self ._insert_query = f"INSERT INTO { self .cid } ({ names } ) VALUES"
127
129
self ._insert_queue .append (params )
128
130
129
- if time .time () - self ._last_insert > self ._insert_interval :
131
+ if (
132
+ len (self ._insert_queue ) >= self ._insert_every
133
+ or time .time () - self ._last_insert > self ._insert_interval
134
+ ):
130
135
self ._commit ()
131
136
return
132
137
You can’t perform that action at this time.
0 commit comments