File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -133,9 +133,11 @@ async def dispatch(
133
133
payload = EXCLUDED.payload,
134
134
updated_at = NOW()
135
135
"""
136
+ else :
137
+ query += "ON CONFLICT (hash) DO NOTHING"
136
138
137
139
try :
138
- await Postgres .execute (
140
+ res = await Postgres .execute (
139
141
query ,
140
142
event .id ,
141
143
event .hash ,
@@ -156,14 +158,15 @@ async def dispatch(
156
158
) from e
157
159
158
160
except Postgres .UniqueViolationError as e :
159
- if reuse :
160
- raise ConstraintViolationException (
161
- "Unable to reuse the event. Another event depends on it" ,
162
- ) from e
163
161
raise ConstraintViolationException (
164
- "Event with same hash already exists " ,
162
+ "Unable to reuse the event. Another event depends on it " ,
165
163
) from e
166
164
165
+ if (not reuse ) and res == "INSERT 0 0" :
166
+ raise ConstraintViolationException (
167
+ "Event with the same hash already exists" ,
168
+ )
169
+
167
170
depends_on = (
168
171
str (event .depends_on ).replace ("-" , "" ) if event .depends_on else None
169
172
)
You can’t perform that action at this time.
0 commit comments