Skip to content

Commit ad04cd6

Browse files
author
Johann Saunier
committed
Fix memory leak
1 parent 4dd4670 commit ad04cd6

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/Consumer.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ public function __construct(AMQPQueue $queue, LoopInterface $loop, $interval, $m
6363
$this->loop = $loop;
6464
$this->max = $max;
6565
$this->timer = $this->loop->addPeriodicTimer($interval, $this);
66+
67+
$this->on('close_amqp_consumer', [$this, 'close']);
6668
}
6769

6870
/**
@@ -75,15 +77,14 @@ public function __invoke()
7577
if ($this->closed) {
7678
throw new BadMethodCallException('This consumer object is closed and cannot receive any more messages.');
7779
}
80+
7881
$counter = 0;
7982
while ($envelope = $this->queue->get()) {
8083
$this->emit('consume', [$envelope, $this->queue]);
8184
if ($this->max && ++$counter >= $this->max) {
8285
return;
8386
}
8487
}
85-
86-
$this->on('close_amqp_consumer', [$this, 'close']);
8788
}
8889

8990
/**

0 commit comments

Comments
 (0)