Personally I would say okay for something up to two or three hours worth. Consider it an investment in your future job.
The alternative is a white-board coding task, where your risk of hitting something that you are really unprepared for is much, much higher.
DISCLAMER: I have given out homework in the 1.5 to 2 hour range as a hiring manager. A smallish, self contained problem (without any commercial value), just to see the candidates actually can write working code - and to get an idea about their angle of attack for the problem..
My understanding after the fact was that this type of thing helped to identify people who were of an open mindset, the challenge put me out of my comfort zone a little too so that was another aspect. Finally it when the review happened it allowed us to talk about something we both had an understanding of.
The only memorable time was when I identified some problems in their brief, ones they didn't notice, and called them out on it (not in a cocky way). This was the nail in the coffin for other candidates as no one else spotted it.
Finally I've never been asked to do anything for an ongoing or upcoming project, only for something that had already existed. They also supplied content for me to work with and I chose what I could do with them in the context of what the role involved.