**How to reproduce**
```
for i in {1..1000}; do echo 'Hello, world!' | clickhouse-local --query "SELECT * FROM table" --structure 's String' | wc -c; done
```

This script hangs.
#include "BackgroundSchedulePool.h"
#include <Common/Exception.h>
#include <Common/setThreadName.h>
#include <Common/Stopwatch.h>
#include <Common/CurrentThread.h>
#include <common/logger_useful.h>
#include <chrono>
#include <ext/scope_guard.h>
namespace DB
{
class TaskNotification final : public Poco::Notification
{
public:
    explicit TaskNotification(const BackgroundSchedulePoolTaskInfoPtr & task_) : task(task_) {}