I would do it like this:
SELECT t.taskid
FROM tasks t
CROSS
JOIN (SELECT @var_sum := 0) a
WHERE IF(@var_sum<10, @var_sum := @var_sum+t.taskid, @var_sum := NULL) IS NOT NULL
This is checking if the current value of @var_sum
is less than 10 (or less than whatever, or less than or equal to whatever. If it is, we add the taskid value to @var_num, and the row is included in the resultset. But when the current value of @var_sum doesn't meet the condition, we assign a NULL to it, and the row does not get included.
NOTE The order of rows returned from the tasks
table is not guaranteed. MySQL can return the rows in any order; it may look deterministic in your testing, but that's likely because MySQL is choosing the same access plan against the same data.